standardize | R Documentation |
Standardize a vector. Can use weights and robust measures of central tendency and dispersion. Returns a clean vector as opposed to base-r's scale
.
standardize(x, w = NULL, robust = F, sample = T, focal_group = NULL)
x |
(num vector) A vector of values. |
w |
(num vector) A vector of weights. |
robust |
(log vector) Whether to use robust measures (default false). See |
sample |
(log scalar) Whether this is a sample as opposed to a population (default true). |
focal_group |
(lgl vector) A subset of the data to standardize the values to. This is useful when you want one subgroup to be the focal group, using their mean/sd as 0/1. |
set.seed(1)
X = rnorm(100, mean = 10, sd = 5)
set.seed(1)
W = runif(100)
standardize(X, W)
standardize(X, robust = T) #almost the same for these data
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.