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)
A list of objects of same class as x
Variables to split data frame by, as as.quoted
variables, a formula or character vector.
A dataframe or matrix
Logical, should data be centered.
Logical, should data be scaled.
Søren Højsgaard, sorenh@math.aau.dk
orderBy
, order_by
,
summaryBy
, summary_by
,
transformBy
, transform_by
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)
Run the code above in your browser using DataLab