powered by
Takes in variable and calculates standard deviation, works with sampling weights. Makes use of the wtd.var function, part of the Hmisc package.
wtd.sd(x, w = NULL, data, digits = 3, ...)
Returns the standard deviation of the variable, a numeric value.
A variable (must be numeric), should be in dataset$var form unless dataset specified in optional data argument.
(Optional) Sampling weights of variable, must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument.
(Optional) Name of dataset that contains x (and w) variable.
(Optional) Number of decimal places reported in result (defaults to 3).
(Optional) Additional arguments passed to Hmisc::wtd.var function.
library(RCPA3) wtd.sd(x=nes$ft.socialists, w=nes$wt) wtd.sd(x=nes$ft.socialists)
Run the code above in your browser using DataLab