cps_read_year: Load a single CPS file

Description Usage Arguments Value

View source: R/cps_read.R

Description

Read one year of data from the Current Population Survey

Usage

1
2
3
4
5
6
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


cpsvote documentation built on Nov. 8, 2020, 4:27 p.m.