setFilter {tabshiftr}R Documentation

Set filters

Description

This function allows to specify additional rules to filter certain rows

Usage

setFilter(schema = NULL, rows = NULL, columns = NULL, operator = NULL)

Arguments

schema

[schema(1)]
In case this information is added to an already existing schema, provide that schema here (overwrites previous information).

rows

[integerish(.)]
rows that are mentioned here are kept.

columns

[integerish(.)]
columns that are mentioned here are kept.

operator

[function(1)]
Logic operators by which the current filter should be combined with the directly preceeding filter; hence this argument is not used in case no other filter was defined before it.

Value

An object of class schema.

See Also

Other functions to describe table arrangement: setCluster(), setFormat(), setGroups(), setIDVar(), setObsVar()

Examples

(input <- tabs2shift$messy_rows)

# select rows where there is 'unit 2' in column 1 or 'year 2' in column 2
schema <-
  setFilter(rows = .find(pattern = "unit 2", col = 1)) %>%
  setFilter(rows = .find(pattern = "year 2", col = 2), operator = `|`) %>%
  setIDVar(name = "territories", columns = 1) %>%
  setIDVar(name = "year", columns = 2) %>%
  setIDVar(name = "commodities", columns = 3) %>%
  setObsVar(name = "harvested", columns = 5) %>%
  setObsVar(name = "production", columns = 6)

reorganise(schema = schema, input = input)

[Package tabshiftr version 0.4.1 Index]