Title: | Centering and Scaling of Numeric Data |
---|---|
Description: | Provides a simple method for centering and scaling of numeric data. Certain columns or rows can be ignored when normalizing or be normalized jointly. |
Authors: | Lennart Oelschläger [aut, cre] |
Maintainer: | Lennart Oelschläger <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.1.0 |
Built: | 2024-12-27 04:58:11 UTC |
Source: | https://github.com/loelschlaeger/normalize |
normalize numeric
data saved as a vector
, matrix
,
data.frame
, or list
to have zero mean and / or unit variance
normalize(x, center = TRUE, scale = TRUE, ...) ## S3 method for class 'numeric' normalize(x, center = TRUE, scale = TRUE, ...) ## S3 method for class 'matrix' normalize( x, center = TRUE, scale = TRUE, byrow = FALSE, ignore = integer(), jointly = list(), ... ) ## S3 method for class 'data.frame' normalize( x, center = TRUE, scale = TRUE, byrow = FALSE, ignore = integer(), jointly = list(), ... ) ## S3 method for class 'list' normalize(x, center = TRUE, scale = TRUE, ...)
normalize(x, center = TRUE, scale = TRUE, ...) ## S3 method for class 'numeric' normalize(x, center = TRUE, scale = TRUE, ...) ## S3 method for class 'matrix' normalize( x, center = TRUE, scale = TRUE, byrow = FALSE, ignore = integer(), jointly = list(), ... ) ## S3 method for class 'data.frame' normalize( x, center = TRUE, scale = TRUE, byrow = FALSE, ignore = integer(), jointly = list(), ... ) ## S3 method for class 'list' normalize(x, center = TRUE, scale = TRUE, ...)
x |
an object to be normalized |
center |
|
scale |
|
... |
further arguments to be passed to or from other methods |
byrow |
|
ignore |
an |
jointly |
a |
the normalized input x
with the numeric
centering and scaling
values used (if any) added as attributes "center"
and "scale"
(ignored columns and rows get centering and scaling values of NA
)
# can normalize numeric vectors, matrices, data.frames, and lists of those normalize( list( c(-3, 0, 3), matrix(1:12, nrow = 3, ncol = 4), data.frame(a = 1:3, b = 4:6, c = 7:9, d = 10:12) ) ) # can ignore columns (or rows) normalize( data.frame(a = 1:3, b = c("A", "B", "C"), c = 7:9, d = 10:12), ignore = 2 ) # can normalize columns (or rows) jointly normalize( matrix(1:12, nrow = 3, ncol = 4), jointly = list(1:2, 3:4) )
# can normalize numeric vectors, matrices, data.frames, and lists of those normalize( list( c(-3, 0, 3), matrix(1:12, nrow = 3, ncol = 4), data.frame(a = 1:3, b = 4:6, c = 7:9, d = 10:12) ) ) # can ignore columns (or rows) normalize( data.frame(a = 1:3, b = c("A", "B", "C"), c = 7:9, d = 10:12), ignore = 2 ) # can normalize columns (or rows) jointly normalize( matrix(1:12, nrow = 3, ncol = 4), jointly = list(1:2, 3:4) )