Split a dataframe into a list according to the levels of variables in the dataframe and scale the numeric variables in each dataframe in the list.
scaleBy(formula, data = parent.frame(), center =TRUE, scale =TRUE)scale_by(data, formula, center =TRUE, scale =TRUE)
Arguments
formula: Variables to split data frame by, as as.quoted
variables, a formula or character vector.
data: A dataframe or matrix
center: Logical, should data be centered.
scale: Logical, should data be scaled.
Returns
A list of objects of same class as x
Examples
scaleBy(~Species, data=iris, center=TRUE, scale=FALSE)scaleBy(~1, data=iris, center=TRUE, scale=FALSE)scale_by(iris,~Species)scale_by(iris,~1)## Not combine list of dataframes to one dataframe e.g. as:a <- scale_by(iris,~Species)d <- do.call(rbind, a)