ff_acs_filter: Filter rows in ACS data based on column text describing the...

View source: R/cleaning.R

ff_acs_filterR Documentation

Filter rows in ACS data based on column text describing the row

Description

With this function, users can imput a regular expression and column with descriptive text, and the dataset will be filtered based on the regualr expression.

Usage

ff_acs_filter(
  df,
  filter_column,
  filter_re,
  subtype_re = NULL,
  recode = F,
  recode_list = NULL
)

Arguments

df

Dataframe of ACS data

filter_column

Column name that contains descriptive text to filter for, entered as object

filter_re

Regular expression used to filter on

subtype_re

Regular expression to further extract words from 'filter_re' and place in a new column called 'subtype'

recode

Boolean indicating whether to recode the newly created 'subtype' column

recode_list

A named list mapping the recode values

Details

Users can also extract a section of the regular expression, and place this phrase into a different column titled 'subtype'. Finally users can recode the newly created 'subtype' column by enting a named list of values.

Value

A dataframe only containing the filtered rows; and an additiona lcolumn called 'subtype' if 'recode = T'.

Examples

age_bins <- list(`16 to 26 year old` = "16 to 25",
                 `75 and over` = "over 75")

ff_acs_filter(employment, description, "AGE -", "[0-9].*",


forsythfuture/FFtools documentation built on April 5, 2022, 10:02 p.m.