scale_by: scale_by

Description Usage Arguments Value Examples

View source: R/scale_by.R

Description

scale_by

Usage

1
scale_by(object = NULL, data = NULL, scale = 1)

Arguments

object

NULL

data

NULL

scale

NULL

Value

center and scales a numeric variable within each level of a factor (or the interaction of several factors

Examples

1
2
3
4
5
6
7
if (interactive()) {
  dat <- data.frame(
  f1 = rep(c("a", "b", "c"), c(5, 10, 20)),
  x1 = rnorm(35, rep(c(1, 2, 3), c(5, 10, 20)),
  rep(c(.5, 1.5, 3), c(5, 10, 20))))
  dat$x1_scaled_by_f1 <- scale_by(x1 ~ f1, dat)
}

demar01/PeCorA documentation built on Feb. 4, 2021, 8:44 p.m.