Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Dec 3, 2023
1 parent 94cc5cd commit 4de562f
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions R/utils_pca_efa.R
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ predict.parameters_efa <- function(object,
...) {
attri <- attributes(object)

if (inherits(attri$model, c("psych", "principal"))) {
if (inherits(attri$model, c("psych", "principal", "psych", "fa"))) {
if (is.null(newdata)) {
if ("scores" %in% names(attri)) {
out <- as.data.frame(attri$scores)
Expand All @@ -167,23 +167,6 @@ predict.parameters_efa <- function(object,
# psych:::predict.principal(object, data)
out <- stats::predict(attri$model, data = newdata)
}
} else if (inherits(attri$model, c("psych", "fa"))) {
if (is.null(newdata)) {
if ("scores" %in% names(attri)) {
out <- as.data.frame(attri$scores)
if (isTRUE(keep_na)) {
# Because pre-made scores don't preserve NA
out <- .merge_na(object, out)
}
} else {
d <- attri$data_set
d <- d[vapply(d, is.numeric, logical(1))]
out <- as.data.frame(stats::predict(attri$model, data = d))
}
} else {
# psych:::predict.fa(object, data)
out <- as.data.frame(stats::predict(attri$model, newdata = newdata))
}
} else if (inherits(attri$model, "spca")) {
# https://github.com/erichson/spca/issues/7
newdata <- newdata[names(attri$model$center)]
Expand Down

0 comments on commit 4de562f

Please sign in to comment.