compute_percentiles: Compute percentiles.

View source: R/compute_functions.R

compute_percentilesR Documentation

Compute percentiles.

Description

\lifecycle

experimental Compute the weighted percentages for a LIS or LWS variable.

Usage

compute_percentiles(
  file,
  file_name,
  variable,
  breaks = seq(0, 1, 0.1),
  weight = NULL,
  na.rm = FALSE
)

Arguments

file

A LIS or LWS file.

file_name

The name of the LIS or LWS file.

variable

A character vector of length one with the indicator that needs to be transformed.

breaks

A numeric vector specifying the percentiles that should be computed. Defaults to all deciles.

weight

A string with the name of the variable in 'file' that should be used as sample weights.

na.rm

A boolean indicating if the computation should ignore missing values in 'variable' and 'weight'.

Details

It uses 'pwgt' or 'hwgt' to weight the indicator.

Value

A data.frame with two columns: 'percentile' and 'value'. The first contains the label of the percentiles computed (e.g. '0.5' for median, '0.2' for first quintile). The second contains the values of these in the distribution of 'variable'.

Examples

## Not run: 
lissy_datasets <- read_lissy_files(c("fr84h", "fr94h", "fr10h"))
compute_percentiles(lissy_datasets[["fr1984h"]], variable = "dhi", na.rm = TRUE)

## End(Not run)

JosepER/lissyrtools documentation built on Jan. 26, 2025, 10:01 p.m.