Scale data.

scale_data2(
  x,
  center = TRUE,
  method = c("auto", "uv", "range", "pareto", "none")
)

Arguments

x

data.frame or mass_dataset. Rows are variables and columns are samples.

center

center or not. TRUE or FALSE.

method

auto, uv, range, pareto or none.

Value

scaled data.frame.

Author

Xiaotao Shen shenxt1990@outlook.com

Examples

x <- as.data.frame(matrix(1:10, ncol = 5))
colnames(x) = letters[1:5]
scale_data1(x, method = "auto")
#>           a          b c         d        e
#> 1 -1.264911 -0.6324555 0 0.6324555 1.264911
#> 2 -1.264911 -0.6324555 0 0.6324555 1.264911
t(scale(t(x)))
#>              a          b c         d        e
#> [1,] -1.264911 -0.6324555 0 0.6324555 1.264911
#> [2,] -1.264911 -0.6324555 0 0.6324555 1.264911
#> attr(,"scaled:center")
#> [1] 5 6
#> attr(,"scaled:scale")
#> [1] 3.162278 3.162278
scale_data1(x, method = "range")
#>      a     b c    d   e
#> 1 -0.5 -0.25 0 0.25 0.5
#> 2 -0.5 -0.25 0 0.25 0.5
scale_data1(x, method = "pareto")
#>           a         b c        d        e
#> 1 -2.249365 -1.124683 0 1.124683 2.249365
#> 2 -2.249365 -1.124683 0 1.124683 2.249365
scale_data1(x, method = "none")
#>       a  b c d e
#> [1,] -4 -2 0 2 4
#> [2,] -4 -2 0 2 4