Skip to content

Commit

Permalink
rep
Browse files Browse the repository at this point in the history
  • Loading branch information
rhijmans committed Dec 1, 2023
1 parent 95e77f6 commit 456468b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions R/princomp.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
setMethod("princomp", signature(x="SpatRaster"),
function(x, cor=FALSE, nobs=FALSE) {
stopifnot(nlyr(x) > 1)
xcov <- layerCor(x, fun = "cov", na.rm = TRUE)
model <- princomp(covmat = xcov$covariance)
xcov <- layerCor(x, fun="cov", na.rm=TRUE)
model <- princomp(covmat = xcov$covariance)
model$center <- diag(xcov$mean)
model$n.obs <- ncell(x) - global(anyNA(x), sum)$sum
if (cor) {
## Calculate scale as population sd like in in princomp
model$n.obs <- ncell(x) - global(anyNA(x), sum)$sum
Expand Down

0 comments on commit 456468b

Please sign in to comment.