wtd.quantile: Finds the Quantile Values of Variable With Option for Weights

View source: R/helper.functions.r

wtd.quantileR Documentation

Finds the Quantile Values of Variable With Option for Weights

Description

Takes in variable and calculates desired quantile values, works with sampling weights. Makes use of the wtd.quantile function from the Hmisc package. See wtd.stats documentation for details.

Usage

wtd.quantile(x, w = NULL, data, q = c(5, 10, 25, 50, 75, 90, 95),
  digits = 3, ...)

Arguments

x

A variable (must be numeric), should be in dataset$var form unless dataset specified in optional data argument.

w

(Optional) Sampling weights of variable, must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument.

data

(Optional) Name of dataset that contains x (and w) variable.

q

(Optional) The quantiles you want calculated as a number or vector of numbers. Input as percentages. For median only, q=50. For quartiles, q=c(25, 50, 75).

digits

(Optional) Number of decimal places reported in result (defaults to 3).

...

(Optional) Additional arguments passed to Hmisc::wtd.quantile function.

Value

Returns quantile values of a variable, a vector of numeric values.

Examples

   library(RCPA3)
   
   wtd.quantile(x=nes$ft.police, q=c(25, 50, 75), w=nes$wt)
   wtd.quantile(x=nes$ft.police, q=c(25, 50, 75))

RCPA3 documentation built on May 29, 2024, 12:19 p.m.

Related to wtd.quantile in RCPA3...