diff --git a/R/confirmatoryfactoranalysis.R b/R/confirmatoryfactoranalysis.R index 827f7cdd..c7581f8f 100644 --- a/R/confirmatoryfactoranalysis.R +++ b/R/confirmatoryfactoranalysis.R @@ -164,7 +164,9 @@ confirmatoryFactorAnalysisInternal <- function(jaspResults, dataset, options, .. return(dataset) } - if (!isSymmetric(as.matrix(dataset))) .quitAnalysis(gettext("Input data does not seem to be a symmetric matrix! Please check the format of the input data.")) + dtmp <- as.matrix(dataset) + colnames(dtmp) <- NULL # otherwise isSymmetric complains + if (!isSymmetric(as.matrix(dtmp))) .quitAnalysis(gettext("Input data does not seem to be a symmetric matrix! Please check the format of the input data.")) vars <- unlist(lapply(options[["factors"]], `[[`, "indicators"), use.names = FALSE) @@ -175,9 +177,8 @@ confirmatoryFactorAnalysisInternal <- function(jaspResults, dataset, options, .. usedvars <- vars[!duplicateVars] var_idx <- match(usedvars, colnames(dataset)) mat <- try(as.matrix(dataset[var_idx, var_idx])) - if (inherits(mat, "try-error") || any(is.na(mat))) - .quitAnalysis(gettext("Input data does not seem to be a covariance matrix! Please check the format of the input data. - All cells must be numeric, and the number of rows must equal the number of columns.")) + if (inherits(mat, "try-error")) + .quitAnalysis(gettext("All cells must be numeric.")) if (options[["group"]] != "") .quitAnalysis(gettext("Grouping variable not supported for covariance matrix input")) diff --git a/R/exploratoryfactoranalysis.R b/R/exploratoryfactoranalysis.R index 1bf84bc8..c33f2553 100644 --- a/R/exploratoryfactoranalysis.R +++ b/R/exploratoryfactoranalysis.R @@ -215,10 +215,8 @@ exploratoryFactorAnalysisInternal <- function(jaspResults, dataset, options, ... # I can use stop() because it's caught by the try and the message is put on # on the modelcontainer. if (ncomp == 0) - stop( - gettext("No factors with an eigenvalue > "), options$eigenValuesBox, ". ", - gettext("Maximum observed eigenvalue equals "), round(max(parallelResult$fa.values), 3) - ) + .quitAnalysis( gettextf("No factors with an eigenvalue > %1$s. Maximum observed eigenvalue equals %2$s.", + options$eigenValuesAbove, round(max(parallelResult$fa.values), 3))) return(ncomp) } } diff --git a/R/principalcomponentanalysis.R b/R/principalcomponentanalysis.R index 2872f52d..2a7b81b4 100644 --- a/R/principalcomponentanalysis.R +++ b/R/principalcomponentanalysis.R @@ -75,14 +75,16 @@ principalComponentAnalysisInternal <- function(jaspResults, dataset, options, .. return(dataset) } - if (!isSymmetric(as.matrix(dataset))) .quitAnalysis(gettext("Input data does not seem to be a symmetric matrix! Please check the format of the input data.")) + dtmp <- as.matrix(dataset) + colnames(dtmp) <- NULL # otherwise isSymmetric complains + if (!isSymmetric(as.matrix(dtmp))) .quitAnalysis(gettext("Input data does not seem to be a symmetric matrix! Please check the format of the input data.")) usedvars <- unlist(options[["variables"]]) var_idx <- match(usedvars, colnames(dataset)) mat <- try(as.matrix(dataset[var_idx, var_idx])) - if (inherits(mat, "try-error") || any(is.na(mat))) - .quitAnalysis("Input data does not seem to be a covariance matrix! Please check the format of the input data. - All cells must be numeric, and the number of rows must equal the number of columns.") + if (inherits(mat, "try-error")) + .quitAnalysis(gettext("All cells must be numeric.")) + .hasErrors(mat, type = "varCovMatrix", message='default', exitAnalysisIfErrors = TRUE) colnames(mat) <- rownames(mat) <- colnames(dataset)[var_idx] @@ -261,10 +263,8 @@ principalComponentAnalysisInternal <- function(jaspResults, dataset, options, .. # I can use stop() because it's caught by the try and the message is put on # on the modelcontainer. if (ncomp == 0) - stop( - gettext("No components with an eigenvalue > "), options$eigenValuesBox, ". ", - gettext("Maximum observed eigenvalue equals "), round(max(parallelResult$pc.values), 3) - ) + .quitAnalysis( gettextf("No factors with an eigenvalue > %1$s. Maximum observed eigenvalue equals %2$s.", + options$eigenValuesAbove, round(max(parallelResult$fa.values), 3))) return(ncomp) } diff --git a/inst/qml/ExploratoryFactorAnalysis.qml b/inst/qml/ExploratoryFactorAnalysis.qml index e055a04f..272384c8 100644 --- a/inst/qml/ExploratoryFactorAnalysis.qml +++ b/inst/qml/ExploratoryFactorAnalysis.qml @@ -109,6 +109,8 @@ Form label: qsTr("Number of factors") defaultValue: 1 min: 1 + max: variables.count > 1 ? variables.count : 1 + } } } diff --git a/inst/qml/PrincipalComponentAnalysis.qml b/inst/qml/PrincipalComponentAnalysis.qml index 88456bbf..fadabaa3 100644 --- a/inst/qml/PrincipalComponentAnalysis.qml +++ b/inst/qml/PrincipalComponentAnalysis.qml @@ -105,6 +105,7 @@ Form label: qsTr("Number of components") defaultValue: 1 min: 1 + max: variables.count > 1 ? variables.count : 1 } } }