px {pxmake} | R Documentation |
Create a px object
Description
Create a px object from a PX-file, an Excel metadata workbook, or a data frame.
Usage
px(input = NULL, data = NULL, validate = TRUE)
Arguments
input |
Optional character string. Can be:
If input is a data frame or NULL, a px object with minimal metadata is created. |
data |
Either a data frame or a path to an |
validate |
Optional. If TRUE a number of validation checks are performed on the px object, and an error is thrown if the object is not valid. If FALSE, the checks are skipped, which can be usefull for large px objects where the check can be time consuming. Use |
Value
A px object
Examples
# Create px object from dataset
x1 <- px(population_gl)
# Download PX-file for example
download_succeeded <- tryCatch({
px_path <- tempfile(fileext = ".px")
url <- "https://bank.stat.gl:443/sq/0cf06962-19f1-4d5c-8d43-b7ed0009617d"
download.file(url, px_path)
TRUE
}, error = function(e) FALSE)
# Run examples only if file was downloaded
if (download_succeeded) {
# Create px object from PX-file
x2 <- px(px_path)
# Create px object from URL
x3 <- px(url)
}
# Create minimal px object
x4 <- px()