kuenm_rpca | R Documentation |
kuenm_rpca performs a principal component analysis with a set of variables and produces raster layers of them. If needed the pricipal components are projected to other scenarios.
kuenm_rpca(variables, in.format, var.scale = TRUE, write.result = TRUE,
out.format = "GTiff", out.dir = "PCA_results", project = FALSE,
proj.vars, n.pcs)
variables |
(character or RasterStack) if character, name of the folder where raster layers are located. If RasterStack, stack of raster layers to be used in principal component analyses. |
in.format |
(character) valid only if |
var.scale |
(logical) wheter or not to scale variables before performing principal component analyses. Default = TRUE. |
write.result |
(logical) whether or not to write PCA results and raster layers (PCs) in |
out.format |
(character) if |
out.dir |
(character) valid if |
project |
(logical) whether or not to project the species niche to other scenario(s).
If TRUE, argument |
proj.vars |
(character or RasterStack) if character, name of the folder where subfolders with environmental
variables of scenarios for projections are (useful if multiple projections are needed). If RasterStack, object
containing stacked variables of only one projection scenario. Variables must correspond with variables in |
n.pcs |
(numeric) number of principal components to be returned as rasters. By default all principal components are returned as RasterLayers. |
If var.scale
= TRUE, variables are centered to cero and scaled using scale
.
A list containing PCA loadings and PCA summary as matrices, as well as one or multiple (if projected) RasterStacks of principal components.
If write.result
= TRUE, all results are written in out.dir
.
# Data
variab <- raster::stack(list.files(system.file("extdata", package = "kuenm"),
pattern = "Mbio_", full.names = TRUE))
names(variab) <- paste0("bio_", c(1, 12, 15, 17))
proj_var <- raster::stack(list.files(system.file("extdata", package = "kuenm"),
pattern = "Gbio_", full.names = TRUE))
names(proj_var) <- paste0("bio_", c(1, 12, 15, 17))
# Example with no projection
npcs <- 3
rpca <- kuenm_rpca(variables = variab, var.scale = TRUE, write.result = FALSE,
n.pcs = npcs)
# Example with projection
project <- TRUE
rpca1 <- kuenm_rpca(variables = variab, var.scale = TRUE, write.result = FALSE,
project = project, proj.vars = proj_var, n.pcs = npcs)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.