View source: R/senate_weights.R
senate_weights | R Documentation |
senate_weights() computes senate weights. These weights are used often to include more than one country with different sample size, yet to scale their weight to a common total.
senate_weights(data, wt, scale, id_k)
data |
data frame object which contains the rest of the arguments |
wt |
observations final weight |
scale |
number to which the weights will be normalized to |
id_k |
a numeric vector of a single variable, to distinguish between countries |
a collection of dplyr::mutate sequences to create normalized and effective sample weights (see Rabe-Hesketh & Skrondal, 2006; Snijder & Bosker, 2012)
the original data frame with the new senate weights at the end, 'ws'
library(dplyr)
data_frame_with_weights <- data_frame %>%
r4sda::senate_weights(.,
scale = 1000,
wt = 'wt',
id_k = 'id_k')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.