View source: R/tensorCentering.R
tensorCentering | R Documentation |
Centers an array of array-valued observations by substracting a location array (the mean array by default) from each observation.
tensorCentering(x, location = NULL)
x |
Array of order at least two with the last dimension corresponding to the sampling units. |
location |
The location to be used in the centering. Either |
Centers a p_1 \times p_2 \times \ldots \times p_r \times n
-dimensional array by substracting the p_1 \times p_2 \times \ldots \times p_r
-dimensional location
from each of the observed arrays.
Array of centered observations with the same dimensions as the input array. The used location is returned as attribute "location"
.
Joni Virta
## Generate sample data.
n <- 1000
x <- t(cbind(rnorm(n, mean = 0),
rnorm(n, mean = 1),
rnorm(n, mean = 2),
rnorm(n, mean = 3),
rnorm(n, mean = 4),
rnorm(n, mean = 5)))
dim(x) <- c(3, 2, n)
## Centered data
xcen <- tensorCentering(x)
## Check the means of individual cells
apply(xcen, 1:2, mean)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.