View source: R/read_codebook.R
read_codebook | R Documentation |
Import meta data from a ddi xml file, and combine its informations with raw csv data file as a dataframe
read_codebook(ddi.file.url, data.file.url)
ddi.file.url |
single text object(URI of a DDI2.5 metadata xml file) |
data.file.url |
single text object(URI of a data csv file) |
This function returns a data frame object with some meta data informations. If a variable contains 'catgry' information in its metadata, the variable is coded as a factor. The csv file could be without header informations. 'ID' of 'var' is used as variable names in the data frame. 'name' of 'var' and 'qstnlit' of 'qstn' are respectively attached as attributes variables. These attributes can be extracted by a general function for attributes(e.g. attributes()), or functions of this package(show.question(), show.varlabel(), show.valuelabel()).
ddi.file.url <- system.file("extdata","samplesurvey2018_ddi.xml",package="DDIR")
data.file.url <- system.file("extdata","samplesurvey2018_data.csv",package="DDIR")
read_codebook(ddi.file.url, data.file.url) -> dataset
head(dataset)
attributes(dataset)
attributes(dataset$Q1)
attributes(dataset$Q2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.