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.
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
Returns
A vector of names, one for each year.
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.
Examples
# read UMich crosswalk from installed filer = 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 withgetNamesPSID("ER17013", cwf, years =2001)getNamesPSID("ER17013", cwf, years =2003)getNamesPSID("ER17013", cwf, years =NULL)getNamesPSID("ER17013", cwf, years = c(2005,2007,2009))