write.px: Write a PC-Axis file

write.pxR Documentation

Write a PC-Axis file

Description

This function writes an object of class px to a PC-Axis file

Usage

write.px(obj.px, filename, heading = NULL, stub = NULL,
         keys = NULL , write.na = FALSE, write.zero = FALSE,
         fileEncoding = "ISO-8859-1")

Arguments

obj.px

The name of a object of class px

filename

The name of the PC-Axis file to create

heading

An optional character vector with the names of variables in the HEADING part of the output file

stub

An optional character vector with the names of the variables in the STUB part of the output file

keys

An optional character vector indicating the variables used as keys

write.na

Whether to write rows with NA values (if keys are used)

write.zero

Whetehr to write rows with 0 values (if keys are used)

fileEncoding

A character string describing the encoding to use in px file (see iconv for details)

Details

The function can write either regular files or files with KEYS.

For regular files, by default, the output file will have a single variable in the HEADING part of the file (columns in the matrix). It is possible to override the default by providing the heading and stub parameters. These are optional, non-overlapping, exhaustive character vectors of names of variables in the output matrix.

It is possible to write files with KEYS which could help reduce the final file size for large and sparse datasets. In such case, it is possible to indicate whether to write rows with all values equal to 0 or NA or not (via arguments write.zero and ·write.na).

Author(s)

Francisco J. Viciana Fernández, Oscar Perpiñan Lamigueiro, Carlos J. Gil Bellosta

References

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

See Also

read.px, as.data.frame.px, as.array.px iconv

Examples

opx1 <- read.px(system.file( "extdata", "example.px", package = "pxR"))
## Not run: 
	write.px(opx1, file = "opx.px")
	write.px(opx1, file = "opx.px",
                   heading = c("sexo", "edad"),
                   stub = "municipios")
        write.px(opx1, filename  = "opx.px",
                 keys = c("municipios","edad"))

## End(Not run)

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