Learn R Programming

pxmake (version 0.17.0)

px_order: Change value order

Description

Inspect or change ORDER.

Usage

px_order(x, value, validate)

# S3 method for px px_order(x, value, validate = TRUE)

Value

A px object or data frame.

Arguments

x

A px object

value

Optional. A data frame with the columns 'order' and one or more of the columns: 'variable-code', and 'code'. If 'value' is missing, the current ORDER is returned. If NULL, ORDER is removed.

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 px_validate() to manually preform the check.

Examples

Run this code
# Set ORDER for a variable
library(tibble)
x1 <-
  population_gl |>
  px() |>
  px_order(tribble(~`variable-code`, ~order,
                       'gender', 8))

# Print ORDER
px_order(x1)

# Set ORDER for a value
x2 <-
  x1 |>
  px_order(tribble(~`variable-code`, ~code, ~order,
                       'age', '2004', 9))
px_order(x2)

# Remove ORDER
x3 <- px_order(x2, NULL)
px_order(x3)

Run the code above in your browser using DataLab