getNamesPSID: GetPSID variables names from various years

View source: R/build.panel.r

getNamesPSIDR Documentation

GetPSID variables names from various years

Description

The user can specify one variable name from any year. This function will find that variable's correct name in any of the years specified by the user. If user does not specify the years variable, return will represent all years in which variable was present.

Usage

getNamesPSID(aname, cwf, years = NULL, file = NULL)

Arguments

aname

A variable name in any of the PSID years

cwf

A data.frame representation of the cross-walk file, (the psid.xlsx file).

years

A vector of years. If NULL, all years in which that variable existed are returned

file

optional file name to write csv

Details

This uses the psid.xlsx crosswalk file from UMich, which is available at http://psidonline.isr.umich.edu/help/xyr/psid.xlsx. In the example, the package openxlsx's read.xlsx is used to import the crosswalk file.

Ask for one variable at a time.

Value

A vector of names, one for each year.

Author(s)

Paul Johnson <pauljohn@ku.edu> and Florian Oswald

Examples

# read UMich crosswalk from installed file
r = system.file(package="psidR")
cwf = openxlsx::read.xlsx(file.path(r,"psid-lists","psid.xlsx"))

# or download directly
# cwf <- read.xlsx("http://psidonline.isr.umich.edu/help/xyr/psid.xlsx")

# then get names with
getNamesPSID("ER17013", cwf, years = 2001)
getNamesPSID("ER17013", cwf, years = 2003)
getNamesPSID("ER17013", cwf, years = NULL)
getNamesPSID("ER17013", cwf, years = c(2005, 2007, 2009))

floswald/psidR documentation built on Feb. 3, 2024, 2:24 a.m.