| readNHES {EdSurvey} | R Documentation |
Connect to NHES Survey Data
Description
Opens a connection to a National Household Education Survey (NHES) data file and
returns an edsurvey.data.frame with
information about the file and data.
Usage
readNHES(savFiles, surveyCode = "auto", forceReread = FALSE, verbose = TRUE)
Arguments
savFiles |
a character vector to the full file path(s) to the NHES extracted SPSS (*.sav) data files. |
surveyCode |
a character vector of the |
forceReread |
a logical value to force a rereading of all processed data.
The default value of |
verbose |
a logical value that defaults to |
Details
Reads in the unzipped public-use files downloaded from the NCES Online Codebook (https://nces.ed.gov/datalab/onlinecodebook) in SPSS (*.sav) format.
Other sources of NHES data, such as restricted-use files or other websites, may require additional conversion steps to generate the required SPSS data format
and/or explicitly setting the surveyCode parameter.
Value
an edsurvey.data.frame if only one NHES file is specified for the savFiles argument,
or an edsurvey.data.frame.list if multiple files are passed to the savFiles argument
Author(s)
Tom Fink
See Also
downloadNHES, getNHES_SurveyInfo, and viewNHES_SurveyCodes
Examples
## Not run:
rootPath <- "~/"
#get instructions for obtaining NHES data
downloadNHES()
#get SPSS *.sav file paths of all NHES files for 2012 and 2016
filesToImport <- list.files(path = file.path(rootPath, "NHES", c(2012, 2016)),
pattern="\\.sav$",
full.names = TRUE,
recursive = TRUE)
#import all files to edsurvey.data.frame.list object
esdfList <- readNHES(savFiles = filesToImport, surveyCode = "auto",
forceReread = FALSE, verbose = TRUE)
viewNHES_SurveyCodes() #view NHES survey codes in console
#get the full file path to the 2016 ATES NHES survey
path_ates2016 <- list.files(path = file.path(rootPath, "NHES", "2016"),
pattern=".*ates.*[.]sav$", full.names = TRUE)
#explicitly setting the surveyCode parameter (if required)
esdf <- readNHES(savFiles = path_ates2016, surveyCode = "ATES_2016",
forceReread = FALSE, verbose = TRUE)
#search for variables in the edsurvey.data.frame
searchSDF(string="sex", data=esdf)
## End(Not run)