File: by_scale.Rd

package info (click to toggle)
r-cran-doby 4.7.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,400 kB
  • sloc: makefile: 2
file content (47 lines) | stat: -rw-r--r-- 1,205 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/by_scaleBy.R
\name{scaleBy}
\alias{scaleBy}
\alias{scale_by}
\title{Group-wise scaling of data}
\usage{
scaleBy(formula, data = parent.frame(), center = TRUE, scale = TRUE)

scale_by(data, formula, center = TRUE, scale = TRUE)
}
\arguments{
\item{formula}{Grouping structure: a formula, character vector, or variables as \code{as.quoted}.}

\item{data}{A data frame or matrix.}

\item{center}{Logical; if TRUE, center the variables.}

\item{scale}{Logical; if TRUE, scale the variables.}
}
\value{
A list of data frames or matrices (same class as input), one per group.
}
\description{
Splits a data frame or matrix by grouping variables and scales numeric variables within each group.
}
\examples{
scale_by(iris, ~Species)
scale_by(iris, ~1)

## Combine result into one data frame:
a <- scale_by(iris, ~Species)
d <- do.call(rbind, a)

## Old interface
scaleBy(~Species, data = iris, center = TRUE, scale = FALSE)
scaleBy(~1, data = iris)

}
\seealso{
\code{\link{summaryBy}}, \code{\link{transformBy}}, \code{\link{orderBy}}
}
\author{
Søren Højsgaard, \email{sorenh@math.aau.dk}
}
\concept{byfunction}
\keyword{utilities}