scaleBy(formula, data, center = TRUE, scale. = TRUE)
y1+y2~f1+f2
where y1 and y2 are numeric
variables and f1 and f2 can be of any type. For each cross-combination
of the values of f1 and f2, the variables (y1,y2) are centered/scaled.
It is valid to write .~f1+f2
. In this case the variables to be
centered/scaled are taken to be all numeric variables in the dataframe
except those that a listed on the right hand side of the formula.
It is valid to write y1+y2~.
. In this case the stratification
is taken to be by all non-numeric variables. If there are no
non-numeric variables, then no stratification is made and a 'global'
centering/scaling is made.
It is valid to write .~.
. In this case the variables to be
centered/scaled are taken to be all numeric variables in the
dataframe. The stratification is made by all non-numeric variables. If
there are no non-numeric variables, then no stratification is made and a 'global'
centering/scaling is made.lapplyBy
,
orderBy
, splitBy
,
summaryBy
,
transformBy
,data(dietox)
# "Remove" the effect of time by centering data within each time point.
dietox2 <- scaleBy(Weight~Time, data=dietox, scale=FALSE)
library(lattice)
xyplot(Weight~Time|Evit+Cu, groups=Pig, data=dietox)
xyplot(Weight~Time|Evit+Cu, groups=Pig, data=dietox2)
Run the code above in your browser using DataLab