cps_read_year {cpsvote}R Documentation

Load a single CPS file

Description

Read one year of data from the Current Population Survey

Usage

cps_read_year(
  file,
  cols = cpsvote::cps_cols,
  names_col = "new_name",
  year = as.numeric(stringr::str_extract(file, "\\d{4}"))
)

Arguments

file

Where the fixed-width or zip/gz file for this year's data lives

cols

Which columns to read. This must be a data frame, with required columns start_pos and end_pos. 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

year

Which year is being read; defaults to 4-digit year in file name

Value

a data frame, with dimensions depending on the year and columns specified


[Package cpsvote version 0.1.0 Index]