Skip to contents

Select only the indicated instances from the flat table by comparison.

Usage

select_instances_by_comparison(ft, not, attributes, comparisons, values)

# S3 method for flat_table
select_instances_by_comparison(
  ft,
  not = FALSE,
  attributes = NULL,
  comparisons,
  values
)

Arguments

ft

A flat_table object.

not

A boolean.

attributes

A list of name vectors.

comparisons

A list of comparison operator vectors.

values

A list of value vectors.

Value

A flat_table object.

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.

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'))
  )