read_codebook: Import meta data from a ddi xml file, and combine its...

View source: R/read_codebook.R

read_codebookR Documentation

Import meta data from a ddi xml file, and combine its informations with raw csv data file as a dataframe

Description

Import meta data from a ddi xml file, and combine its informations with raw csv data file as a dataframe

Usage

read_codebook(ddi.file.url, data.file.url)

Arguments

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)

Value

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()).

Examples


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)


ystnkn/DDIR documentation built on Oct. 17, 2023, 7:37 p.m.