Description Usage Arguments Details Value Methods (by class) Warnings Grouped data frames (dplyr package)
View source: R/fun-normalize.R
Normalize data, i.e. express each point as its deviation from a center.
1 2 3 4 5 6 7 | normalize(x, variables, method = c("median", "mean", "medpolish"), reference)
## S3 method for class 'data.frame'
normalize(x, variables, method = c("median", "mean", "medpolish"), reference)
## S3 method for class 'grouped_df'
normalize(x, variables, method = c("median", "mean", "medpolish"), reference)
|
x |
screen object, i.e. a |
variables |
variables to normalize; character vector of column names or numeric vector of column indices |
method |
normalization method, see |
reference |
logical predicate that defines reference observations, bare or character |
There are three normalization methods available at the moment:
mean
: subtract mean of reference from each data point
median
: subtract median of reference from each data point
medpolish
: run Tukey's median polish and return residuals;
calls stats::medpolish
an invisible data.frame
data.frame
: establishes normalization method, with possible reference
,
and runs it on desired variables with lapply
,
then cbind
s the result to x
grouped_df
: see data.frame__to__grouped_df
If you are using the medpolish method, variables will be temporarily converted
from vectors to matrices. Make sure your data frames are ordered by column
(the default way matrices are filled) rather than by row (the default ScanR format).
Also, row and column specifications are necessary to read the matrix dimensions,
so x
must contain either "row" and "column" variables or a "position" variable.
For other methods a reference subset can be specified. Any logical predicate will do. If no reference is declared, normalization will be done against the whole population.
dplyr
package)The method for class grouped_df
is home made because the native behavior
of grouped data frames does not readily support functions that return data frames.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.