Learn R Programming

pxR (version 0.42.7)

as.data.frame.px: Extraction of data from px into data.frame objects

Description

This function extracts the data component from a px object as a data.frame.

Usage

# S3 method for px
as.data.frame( x, ..., use.codes = FALSE,
                 warnings.as.errors = TRUE, direction = 'long')

Value

A data.frame object.

Arguments

x

a px object

use.codes

If true, this parameter replaces the names (or levels) of the variables by their codes, if available; alternatively, it can be a character vector identifying those variables for which codes will replace the levels of the variables. See details section.

warnings.as.errors

If true, the function will fail in case any issues are found; otherwise, it will generate warnings.

direction

character string, either ‘"wide"’ to reshape to wide format, or ‘"long"’ to reshape to long format (default).

...

Additional arguments, currently not used

Author

Carlos J. Gil Bellosta, Oscar Perpiñán Lamigueiro, Francisco J. Viciana Fernández, Emilio Torres

Details

The PC-Axis provides two alternative mechanisms for naming variables: their values or their codes, usually less verbose. The the use.codes parameter can be used to select those variables for which the CODES attribute in the PC-Axis file for naming the levels of the variables. It should be noted that there may not be CODES for all variables; in such cases, the VALUES are used instead.

The function will operate in 'paranoid mode' unless warnings.as.errors is set to FALSE. In such mode, the function will fail if any issues are found in the data. If warnings.as.errors is set to FALSE, the function will do its best to solve some known issues in some PC-Axis files.

References

https://www.scb.se/globalassets/vara-tjanster/px-programmen/px-file_format_specification_2013.pdf

See Also

read.px, as.array.px

Examples

Run this code
my.px.object <- read.px(system.file("extdata", "example.px",
                                              package = "pxR"))
my.px.data   <- as.data.frame(my.px.object)

Run the code above in your browser using DataLab