Skip to contents

Inspect or change PRECISION.

Usage

px_precision(x, value)

# S3 method for class 'px'
px_precision(x, value)

Arguments

x

A px object

value

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

Value

A px object or data frame.

Examples

# Set PRECISION for a variable
library(tibble)
x1 <-
  population_gl |>
  px() |>
  px_precision(tribble(~`variable-code`, ~precision,
                       'gender', 2))

# Print PRECISION
px_precision(x1)
#> # A tibble: 2 × 3
#>   `variable-code` code   precision
#>   <chr>           <chr>      <dbl>
#> 1 gender          female         2
#> 2 gender          male           2

# Set PRECISION for a value
x2 <-
  x1 |>
  px_precision(tribble(~`variable-code`, ~code, ~precision,
                       'age', '2004', 3))
px_precision(x2)
#> # A tibble: 3 × 3
#>   `variable-code` code   precision
#>   <chr>           <chr>      <dbl>
#> 1 gender          female         2
#> 2 gender          male           2
#> 3 age             2004           3

# Remove PRECISION
x3 <- px_precision(x2, NULL)
px_precision(x3)
#> NULL