cps_read {cpsvote}R Documentation

Read in CPS data

Description

Load multiple years of data from the Current Population Survey. This function will also download the data for you, if it is not present in the given dir.

Usage

cps_read(
  years = seq(1994, 2018, 2),
  dir = "cps_data",
  cols = cpsvote::cps_cols,
  names_col = "new_name",
  join_dfs = TRUE
)

Arguments

years

Which years to read in. Thie function will read data from files in dir whose names contain these 4-digit years.

dir

The folder where the CPS data files live. These files should follow a naming scheme that contains the 4-digit year of the results in question, and have a ".zip" or ".gz" extension.

cols

Which columns to read. This must be a data frame, with required columns start_pos,end_pos, and year. The default value is cps_cols, which reads from the list cpsvote::cps_cols. See vignette("add-variables") for details about how to specify a different set of cols.

names_col

The column in cols that contains column names for the specified columns. If none exists, use names_col = NULL

join_dfs

Whether to combine all of the years into a single data frame, or leave them as a list of data frames. Defaults to TRUE with a warning.

Value

a data frame, or list of data frames

Examples

## Not run: cps_read(years = 2016, names_col = "new_name")


[Package cpsvote version 0.1.0 Index]