diff --git a/DESCRIPTION b/DESCRIPTION index b56d27dfe..bf663afb0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: parameters Title: Processing of Model Parameters -Version: 0.21.2.6 +Version: 0.21.2.7 Authors@R: c(person(given = "Daniel", family = "Lüdecke", @@ -115,7 +115,6 @@ Suggests: drc, DRR, effectsize (>= 0.8.2), - EGAnet (>= 0.7), emmeans (>= 1.7.0), estimatr, factoextra, diff --git a/NEWS.md b/NEWS.md index 8cf33e346..610394769 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,6 +8,9 @@ * `print_md()` for `compare_parameters()` now gains more arguments, similar to the `print()` method. +* `n_factors()` no longer supports `package = "EGAnet"`, as package *EGAnet* was + removed from CRAN. + ## Bug fixes * Fixed issue in `print_html()` for objects from package _ggeffects_. diff --git a/R/n_factors.R b/R/n_factors.R index 853b3c42b..7fe7c12ad 100644 --- a/R/n_factors.R +++ b/R/n_factors.R @@ -22,11 +22,11 @@ #' Principal Components. `"default"` will select `"minres"` if #' `type = "FA"` and `"pc"` if `type = "PCA"`. #' @param package Package from which respective methods are used. Can be -#' `"all"` or a vector containing `"nFactors"`, `"psych"`, `"PCDimension"`, `"fit"` or -#' `"EGAnet"`. Note that `"fit"` (which actually also relies on the `psych` -#' package) and `"EGAnet"` can be very slow for bigger -#' datasets. Thus, the default is `c("nFactors", "psych")`. You must have -#' the respective packages installed for the methods to be used. +#' `"all"` or a vector containing `"nFactors"`, `"psych"`, `"PCDimension"` or +#' `"fit"`. Note that `"fit"` (which actually also relies on the **psych** +#' package) can be very slow for bigger datasets. Thus, the default is +#' `c("nFactors", "psych")`. You must have the respective packages installed +#' for the methods to be used. #' @param safe If `TRUE`, the function will run all the procedures in try #' blocks, and will only return those that work and silently skip the ones #' that may fail. @@ -49,7 +49,7 @@ #' `n_components()` is a convenient short for `n_factors(type = #' "PCA")`. #' -#' @examplesIf require("PCDimension", quietly = TRUE) && require("nFactors", quietly = TRUE) && require("EGAnet", quietly = TRUE) +#' @examplesIf require("PCDimension", quietly = TRUE) && require("nFactors", quietly = TRUE) #' library(parameters) #' n_factors(mtcars, type = "PCA") #' @@ -120,7 +120,7 @@ n_factors <- function(x, n_max = NULL, ...) { if (all(package == "all")) { - package <- c("nFactors", "EGAnet", "psych", "fit", "pcdimension") + package <- c("nFactors", "psych", "fit", "pcdimension") } # Get number of observations @@ -247,25 +247,27 @@ n_factors <- function(x, } } - # EGAnet ------------------------------------------- - if ("EGAnet" %in% package) { - insight::check_if_installed("EGAnet") + # EGAnet was removed from CRAN - if (safe) { - out <- rbind( - out, - tryCatch(.n_factors_ega(x, cor, nobs, eigen_values, type), - # warning = function(w) data.frame(), - error = function(e) data.frame() - ) - ) - } else { - out <- rbind( - out, - .n_factors_ega(x, cor, nobs, eigen_values, type) - ) - } - } + # EGAnet ------------------------------------------- + # if ("EGAnet" %in% package) { + # insight::check_if_installed("EGAnet") + + # if (safe) { + # out <- rbind( + # out, + # tryCatch(.n_factors_ega(x, cor, nobs, eigen_values, type), + # # warning = function(w) data.frame(), + # error = function(e) data.frame() + # ) + # ) + # } else { + # out <- rbind( + # out, + # .n_factors_ega(x, cor, nobs, eigen_values, type) + # ) + # } + # } # psych ------------------------------------------- @@ -545,29 +547,28 @@ print.n_clusters <- print.n_factors } +# EGAnet was removed from CRAN # EGAnet ------------------------ - -#' @keywords internal -.n_factors_ega <- function(x = NULL, - cor = NULL, - nobs = NULL, - eigen_values = NULL, - type = "FA") { - # Replace with own correlation matrix - junk <- utils::capture.output(suppressWarnings(suppressMessages( - nfac_glasso <- EGAnet::EGA(cor, n = nobs, model = "glasso", plot.EGA = FALSE)$n.dim # nolint - ))) - junk <- utils::capture.output(suppressWarnings(suppressMessages( - nfac_TMFG <- EGAnet::EGA(cor, n = nobs, model = "TMFG", plot.EGA = FALSE)$n.dim # nolint - ))) - - .data_frame( - n_Factors = as.numeric(c(nfac_glasso, nfac_TMFG)), - Method = c("EGA (glasso)", "EGA (TMFG)"), - Family = "EGA" - ) -} +# .n_factors_ega <- function(x = NULL, +# cor = NULL, +# nobs = NULL, +# eigen_values = NULL, +# type = "FA") { +# # Replace with own correlation matrix +# junk <- utils::capture.output(suppressWarnings(suppressMessages( +# nfac_glasso <- EGAnet::EGA(cor, n = nobs, model = "glasso", plot.EGA = FALSE)$n.dim # nolint +# ))) +# junk <- utils::capture.output(suppressWarnings(suppressMessages( +# nfac_TMFG <- EGAnet::EGA(cor, n = nobs, model = "TMFG", plot.EGA = FALSE)$n.dim # nolint +# ))) + +# .data_frame( +# n_Factors = as.numeric(c(nfac_glasso, nfac_TMFG)), +# Method = c("EGA (glasso)", "EGA (TMFG)"), +# Family = "EGA" +# ) +# } # psych ------------------------ diff --git a/man/n_factors.Rd b/man/n_factors.Rd index 9146a3ef5..e98aa3c67 100644 --- a/man/n_factors.Rd +++ b/man/n_factors.Rd @@ -49,11 +49,11 @@ Principal Components. \code{"default"} will select \code{"minres"} if \code{type = "FA"} and \code{"pc"} if \code{type = "PCA"}.} \item{package}{Package from which respective methods are used. Can be -\code{"all"} or a vector containing \code{"nFactors"}, \code{"psych"}, \code{"PCDimension"}, \code{"fit"} or -\code{"EGAnet"}. Note that \code{"fit"} (which actually also relies on the \code{psych} -package) and \code{"EGAnet"} can be very slow for bigger -datasets. Thus, the default is \code{c("nFactors", "psych")}. You must have -the respective packages installed for the methods to be used.} +\code{"all"} or a vector containing \code{"nFactors"}, \code{"psych"}, \code{"PCDimension"} or +\code{"fit"}. Note that \code{"fit"} (which actually also relies on the \strong{psych} +package) can be very slow for bigger datasets. Thus, the default is +\code{c("nFactors", "psych")}. You must have the respective packages installed +for the methods to be used.} \item{cor}{An optional correlation matrix that can be used (note that the data must still be passed as the first argument). If \code{NULL}, will @@ -92,7 +92,7 @@ implemented in the \code{n_components()} is a convenient short for \code{n_factors(type = "PCA")}. } \examples{ -\dontshow{if (require("PCDimension", quietly = TRUE) && require("nFactors", quietly = TRUE) && require("EGAnet", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("PCDimension", quietly = TRUE) && require("nFactors", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} library(parameters) n_factors(mtcars, type = "PCA")