epx.class: Helper: Show value labels and convert variables to...

View source: R/convertToClasses.R

epx.classR Documentation

Helper: Show value labels and convert variables to appropriate classes

Description

A helper function of read.EpiData, to replace values by value labels and convert variables to appropriate classes.

Usage

epx.class(dat, info)

Arguments

dat

A data.frame or a list of data.frames created by epx.extract.

info

Additional information about the EpiData-file created by epx.extract.

Details

All date and time fields are convertet using *Coordinated Usual Time (UTC)* as time zone argument as EpiData does not provide time zone information by default.

Value

A data.frame with value labels and appropriate object classes of the variables.

Examples

# This demonstrates the effects of all six helper functions to \code{\link{read.EpiData}}.

(x <- epx.example("SomeFakeData.epx"))

# epx.extract() extracts the information from an EpiData-epx file
(info <- epx.extract(x))

# epx.read() transforms the information into a data.frame
(dat <- lapply(info$perDataSet, epx.read))

# Combine dat and info in a data-set-wise list
# This is a necessary detour to handle EpiData files with multiple data sets.
perDataSet <- mapply(function(dat, info) list(list(dat = dat, info = info)), dat, info[[7]])

# epx.labels() replaces value codes with value labels
(datLab <- epx.labels(perDataSet$ds1$dat, perDataSet$ds1$info))

# epx.missing() replaces definde missing values with NA
(datMis <- epx.missing(perDataSet$ds1$dat, perDataSet$ds1$info))

# epx.class() sets variable classes according to the field types defined in EpiData
(datClass <- epx.class(perDataSet$ds1$dat, perDataSet$ds$info))

# Bringing it all together
read.EpiData(epx.example("SomeFakeData.epx"))

JohannPopp/epidatR documentation built on Jan. 29, 2024, 1:23 a.m.