Calculates the mean for each element of a matrix from a list of FBMs
Source:R/anglemanise_utils.R
big_mat_list_mean.Rd
This function takes an anglemania_object
containing a list of
FBM
s and calculates the mean of every element.
If the list is empty or the FBMs have different dimensions,
it throws an error.
Value
A new FBM
object containing the mean values.
Examples
# Create FBMs
mat1 <- matrix(1:9, nrow = 3)
mat2 <- matrix(1:9, nrow = 3)
fbm1 <- bigstatsr::FBM(nrow = nrow(mat1), ncol = ncol(mat1), init = mat1)
fbm2 <- bigstatsr::FBM(nrow = nrow(mat2), ncol = ncol(mat2), init = mat2)
# Create weights
weights <- c(batch1 = 0.5, batch2 = 0.5)
# Create the list of FBMs
fbm_list <- list(batch1 = fbm1, batch2 = fbm2)
# Construct the anglemania_object
angl <- new(
"anglemania_object",
weights = weights,
matrix_list = fbm_list
)
big_mat_list_mean(angl)
#> A Filebacked Big Matrix of type 'double' with 3 rows and 3 columns.