include_states: Select only rows with given (types of) Indian states or Union...

View source: R/filter_st_name.R

include_statesR Documentation

Select only rows with given (types of) Indian states or Union Territories

Description

Select only rows with given (types of) Indian states or Union Territories

Usage

include_states(
  df,
  ...,
  state_col_name = NULL,
  fixed = FALSE,
  ignore_case = TRUE
)

Arguments

df

An object with class data.frame that has a column of Indian states.

...

State or Union Territory names either in full or in part. Case insensitive. Accepts symbols (bare text) or quoted strings (see details below). If a symbol refers to a character vector in the global environment, the vector contents and not the symbol will be part of the search. The following options are special and can be used in addition to others both as strings and as symbols:

  • "poor_coverage": Jammu & Kashmir and Uttarakhand because of frequent problems in maps and dataset coverage

  • "not_in_cpw1" for those not in Consumer Pyramids Wave 1

  • "small_rich": Goa, Delhi, Puducherry and Chandigarh

  • "no_vidhan": those Union Territories without legislative assembly

  • "northeast": Assam, Arunachal Pradesh, Nagaland, Manipur, Mizoram, Tripura, Meghalaya, Sikkim)

  • "all_above": all states in previous options

state_col_name

If more than column is known to be present, introduce the name of the correct column here as a string.

fixed

should the names be matched strictly.

ignore_case

should case be ignored.

Details

The elements from ... are processed and coerced into a string vectorthat is then turned into a regex by cptools::bound_rx(vector, "", "") ignoring case.

include_states(df, and, "Mizoram", my_states) will include Andhra Pradesh, Mizoram and the contents of my_states if it is a character vector in the call stack.

Value

The same data.frame object WITH ONLY rows referring to the relevant states


AltfunsMA/cptools documentation built on Aug. 7, 2022, 5:44 p.m.