Remove existing values from fields of an IPUMS USA or CPS extract object. All fields are optional, and if omitted, will remain unchanged.

To add new values to an extract, see add_to_extract().

For an overview of ipumsr microdata API functionality, see vignette("ipums-api", package = "ipumsr").

remove_from_extract(extract, ...)

# S3 method for usa_extract
remove_from_extract(extract, samples = NULL, variables = NULL, ...)

# S3 method for cps_extract
remove_from_extract(extract, samples = NULL, variables = NULL, ...)

Arguments

extract

An ipums_extract object.

...

Further arguments passed to methods.

samples

Character vector of samples to remove from the extract, if any.

variables

Character vector of variables to remove from the extract, if any.

Value

A modified IPUMS USA or CPS extract object

Note

If the supplied extract definition comes from a previously submitted extract, this function will reset the definition to an unsubmitted state.

Examples

usa_extract <- define_extract_usa(
  description = "USA example",
  samples = c("us2013a", "us2014a"),
  variables = "YEAR"
)

revised_usa_extract <- remove_from_extract(
  usa_extract,
  samples = "us2014a"
)

revised_usa_extract
#> Unsubmitted IPUMS USA extract 
#> Description: USA example
#> Samples: (1 total) us2013a
#> Variables: (1 total) YEAR


cps_extract <- define_extract_cps(
  description = "CPS example",
  samples = c("cps2019_03s", "cps2020_03s"),
  variables = "YEAR"
)

revised_cps_extract <- remove_from_extract(
  cps_extract,
  samples = "cps2020_03s"
)

revised_cps_extract
#> Unsubmitted IPUMS CPS extract 
#> Description: CPS example
#> Samples: (1 total) cps2019_03s
#> Variables: (1 total) YEAR