Skip to content

Commit

Permalink
fix cov input options
Browse files Browse the repository at this point in the history
  • Loading branch information
juliuspfadt committed Oct 17, 2024
1 parent 46c366b commit b5ad727
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
14 changes: 9 additions & 5 deletions R/confirmatoryfactoranalysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,24 @@ confirmatoryFactorAnalysisInternal <- function(jaspResults, dataset, options, ..

.cfaDataCovariance <- function(dataset, options) {


if (options[["dataType"]] == "raw") {
return(dataset)
}

# possible data matrix?
if ((nrow(dataset) != ncol(dataset)) && !all(dt[lower.tri(dt)] == t(dt)[lower.tri(dt)])) {
.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)

# are there any variables specified at all?
if (length(vars) == 0)
return(data.frame())

# possible data matrix?
if ((nrow(dataset) != ncol(dataset)))
.quitAnalysis(gettext("Input data does not seem to be a square matrix! Please check the format of the input data."))

if (!all(dataset[lower.tri(dataset)] == t(dataset)[lower.tri(dataset)]))
.quitAnalysis(gettext("Input data does not seem to be a symmetric matrix! Please check the format of the input data."))

duplicateVars <- duplicated(vars)
usedvars <- vars[!duplicateVars]
var_idx <- match(usedvars, colnames(dataset))
Expand Down
2 changes: 1 addition & 1 deletion R/exploratoryfactoranalysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ exploratoryFactorAnalysisInternal <- function(jaspResults, dataset, options, ...
# Read dataset
dataset <- .pcaAndEfaReadData(dataset, options)
ready <- length(options$variables) > 1
dataset <- .pcaAndEfaDataCovariance(dataset, options)
dataset <- .pcaAndEfaDataCovariance(dataset, options, ready)

if (ready)
.efaCheckErrors(dataset, options)
Expand Down
12 changes: 8 additions & 4 deletions R/principalcomponentanalysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ principalComponentAnalysisInternal <- function(jaspResults, dataset, options, ..
dataset <- .pcaAndEfaReadData(dataset, options)
ready <- length(options$variables) > 1

dataset <- .pcaAndEfaDataCovariance(dataset, options)
dataset <- .pcaAndEfaDataCovariance(dataset, options, ready)

if (ready)
.pcaCheckErrors(dataset, options)
Expand Down Expand Up @@ -69,16 +69,20 @@ principalComponentAnalysisInternal <- function(jaspResults, dataset, options, ..
}


.pcaAndEfaDataCovariance <- function(dataset, options) {
.pcaAndEfaDataCovariance <- function(dataset, options, ready) {

if (!ready) return()

if (options[["dataType"]] == "raw") {
return(dataset)
}

# possible data matrix?
if ((nrow(dataset) != ncol(dataset)) && !all(dt[lower.tri(dt)] == t(dt)[lower.tri(dt)])) {
if ((nrow(dataset) != ncol(dataset)))
.quitAnalysis(gettext("Input data does not seem to be a square matrix! Please check the format of the input data."))

if (!all(dataset[lower.tri(dataset)] == t(dataset)[lower.tri(dataset)]))
.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))
Expand Down
1 change: 1 addition & 0 deletions inst/qml/ExploratoryFactorAnalysis.qml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Form
RadioButtonGroup
{
name: "dataType"
id: dataType
columns: 2
RadioButton { value: "raw"; label: qsTr("Raw"); checked: true }
RadioButton
Expand Down

0 comments on commit b5ad727

Please sign in to comment.