if (FALSE) { # requireNamespace("bigmemory", quietly = TRUE)
set.seed(456)
mat <- bigmemory::as.big.matrix(matrix(rnorm(30), nrow = 6))
ncomp <- 2
rotation_store <- bigmemory::big.matrix(ncol(mat), ncomp, type = "double")
pca_stream <- pca_stream_bigmatrix(mat, xpRotation = rotation_store, ncomp = ncomp)
score_store <- bigmemory::big.matrix(nrow(mat), ncomp, type = "double")
pca_scores_stream_bigmatrix(
mat,
score_store,
pca_stream$rotation,
pca_stream$center,
pca_stream$scale,
ncomp = ncomp
)
loadings_store <- bigmemory::big.matrix(ncol(mat), ncomp, type = "double")
pca_variable_loadings_stream_bigmatrix(
pca_stream$rotation_stream_bigmatrix,
pca_stream$sdev,
loadings_store
)
correlation_store <- bigmemory::big.matrix(ncol(mat), ncomp, type = "double")
pca_variable_correlations_stream_bigmatrix(
pca_stream$rotation_stream_bigmatrix,
pca_stream$sdev,
pca_stream$column_sd,
pca_stream$scale,
correlation_store
)
contribution_store <- bigmemory::big.matrix(ncol(mat), ncomp, type = "double")
pca_variable_contributions_stream_bigmatrix(
loadings_store,
contribution_store
)
}
Run the code above in your browser using DataLab