From 51adc1ca52325833e5cb1e4bd87e3bac42397c5a Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 27 Oct 2022 21:48:16 +0200 Subject: [PATCH] minor --- R/n_factors.R | 7 ++++--- R/principal_components.R | 5 +---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/R/n_factors.R b/R/n_factors.R index 7fc55f9a0..7afc40e5c 100644 --- a/R/n_factors.R +++ b/R/n_factors.R @@ -131,15 +131,16 @@ n_factors <- function(x, nobs <- x package <- package[!package %in% c("pcdimension", "PCDimension")] } else if (is.matrix(x) || inherits(x, "easycormatrix")) { - stop("Please input the correlation matrix via the `cor = ...` argument and - the number of rows / observations via the first argument.") + insight::format_error( + "Please input the correlation matrix via the `cor = ...` argument and the number of rows / observations via the first argument." + ) } } else { nobs <- nrow(x) } # Get only numeric - x <- x[sapply(x, is.numeric)] + x <- x[vapply(x, is.numeric, logical(1))] # Correlation matrix if (is.null(cor)) { diff --git a/R/principal_components.R b/R/principal_components.R index 52a51195f..be322d349 100644 --- a/R/principal_components.R +++ b/R/principal_components.R @@ -263,7 +263,7 @@ principal_components.data.frame <- function(x, x <- stats::na.omit(x) # Select numeric only - x <- x[sapply(x, is.numeric)] + x <- x[vapply(x, is.numeric, logical(1))] # N factors n <- .get_n_factors(x, n = n, type = "PCA", rotation = rotation) @@ -456,9 +456,6 @@ principal_components.data.frame <- function(x, # rotate loadings insight::check_if_installed("psych", reason = sprintf("`%s`-rotation.", rotation)) - if (!requireNamespace("psych", quietly = TRUE)) { - insight::format_error(sprintf("Package `psych` required for `%s`-rotation.", rotation)) - } pca <- psych::principal(x, nfactors = n, rotate = rotation, ...) msa <- psych::KMO(x)