Learn R Programming

doBy (version 4.6.22)

by_scale: Scale a dataframe or matrix

Description

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.

Usage

scaleBy(formula, data = parent.frame(), center = TRUE, scale = TRUE)

scale_by(data, formula, center = TRUE, scale = TRUE)

Value

A list of objects of same class as x

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.

Author

Søren Højsgaard, sorenh@math.aau.dk

See Also

orderBy, order_by, summaryBy, summary_by, transformBy, transform_by

Examples

Run this code

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