
Select instances of a flat table by comparison
Source:R/flat_table_transform.R
select_instances_by_comparison.RdSelect only the indicated instances from the flat table by comparison.
Usage
select_instances_by_comparison(ft, not, attributes, comparisons, values)
# S3 method for class 'flat_table'
select_instances_by_comparison(
ft,
not = FALSE,
attributes = NULL,
comparisons,
values
)Details
The elements of the three parameter lists correspond (all three must have the same structure and length or be of length 1). AND is performed for each combination of attribute, operator and value within each element of each list and OR between elements of the lists.
If the parameter not is true, the negation operation will be applied to the
result.
See also
Other flat table transformation functions:
add_custom_column(),
remove_instances_without_measures(),
replace_empty_values(),
replace_string(),
replace_unknown_values(),
select_attributes(),
select_instances(),
select_measures(),
separate_measures(),
transform_attribute_format(),
transform_from_values(),
transform_to_attribute(),
transform_to_measure(),
transform_to_values()
Examples
ft <- flat_table('iris', iris) |>
select_instances_by_comparison(attributes = 'Species',
comparisons = '>=',
values = 'v')
ft <- flat_table('ft_num', ft_num) |>
select_instances_by_comparison(
not = FALSE,
attributes = c('Year', 'Year', 'WEEK'),
comparisons = c('>=', '<=', '=='),
values = c('1962', '1964', '2')
)
ft <- flat_table('ft_num', ft_num) |>
select_instances_by_comparison(
not = FALSE,
attributes = c('Year', 'Year', 'WEEK'),
comparisons = c('>=', '<=', '=='),
values = list(c('1962', '1964', '2'),
c('1962', '1964', '4'))
)