View source: R/poisson_scale.R
| poisson_scale | R Documentation |
This function performs Poisson scaling on a numeric matrix or data frame. Poisson scaling scales each variable by its square root mean value, with an optional scaling offset to avoid over-scaling when a variable has a near-zero mean.
poisson_scale(
x,
sc = NULL,
drop_na = TRUE,
options = list(),
drop.na = deprecated()
)
x |
A numeric matrix or data frame. |
sc |
A vector of previously calculated scales. If provided, these scales will be applied to the data. |
drop_na |
A logical value indicating whether to remove rows containing
missing values. If |
options |
A list of options for Poisson scaling. See the 'Options' section below. |
drop.na |
If sc is not provided, the function returns a list with the following components:
xs |
The Poisson-scaled data. |
sc |
A vector of scales calculated for the given data. |
If sc is provided, the function returns the Poisson-scaled data xs.
The options argument is a list with the following fields:
offset: A numeric value representing the percentage of the maximum mean value to be used as an offset on all scales. Avoids division by near-zero means. Default is 3.
mode: An integer value (1 or 2) specifying the dimension of the data on which to calculate the mean value for scaling. 1 = mean over rows (to scale variables); 2 = mean over columns (to scale samples). Default is 1.
Christian L. Goueguel
data(forageLIBS)
spectra <- forageLIBS[-(1:14)] # the spectral channels
res <- poisson_scale(spectra[1:300, ])
head(res$sc)
# the same scales for new spectra
poisson_scale(spectra[301:368, ], sc = res$sc)[1:3, 1:4]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.