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

View source: R/as.data.frame.px.R

as.data.frame.pxR Documentation

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 class 'px'
as.data.frame( x, ..., use.codes = FALSE,
                 warnings.as.errors = TRUE, direction = 'long')

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

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.

Value

A data.frame object.

Author(s)

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

References

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

See Also

read.px, as.array.px

Examples

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

pxR documentation built on Nov. 23, 2022, 9:06 a.m.