Learn R Programming

RCPA3 (version 1.3.1)

wtd.median: Find Median of Variable with Option to Weight Observations

Description

Takes in variable and finds median, works with sampling weights. Makes use of the wtd.quantile function, part of the Hmisc package.

Usage

wtd.median(x, w = NULL, data, ...)

Value

Returns the median value of the variable

Arguments

x

A variable

w

(Optional) Sampling weights of variable

data

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

Examples

Run this code
   library(RCPA3)
   
   wtd.median(x=nes$approve.pres.hc, w=nes$wt)
   wtd.median(x=nes$approve.pres.hc)

Run the code above in your browser using DataLab