stand | R Documentation |
Standardize regression inputs by centering around the mean and dividing by 2 standard deviations
stand(x, cols = NULL)
x |
A vector, matrix, or dataframe |
cols |
A character vector of column names, a numeric vector of column indices, or a formula |
Inspired by the standardize
function in the arm
package. Numeric predictors are rescaled by subtracting the mean and dividing by 2 standard deviations. Binary predictors are rescaled to have a mean of 0 and a difference of 1 between their two levels. Non-numeric variables with more than two values are unchanged.
A numeric vector, a matrix, or a dataframe
Jason Grafmiller
standardize
## Not run:
x <- rnorm(10, 5, 3)
x
stand(x)
y <- sample(c("A", "B"), 10, replace = T, prob = c(.8, .2))
y
stand(y)
df <- data.frame(X = x, Y = y)
df
stand(df, 1:2)
stand(df, Y ~ X)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.