@@ -78,6 +78,12 @@ principalComponentAnalysisInternal <- function(jaspResults, dataset, options, ..
78
78
return (dataset )
79
79
}
80
80
81
+ # it seems the column names are sorted alphabetically when all columns are read
82
+ # so we need to sort the column names to match the order of the variables
83
+ sortedIndices <- sort(as.numeric(gsub(" .*_(\\ d+)_.*" , " \\ 1" , colnames(dataset ))))
84
+ sortedNames <- paste0(" JaspColumn_" , sortedIndices , " _Encoded" )
85
+ dataset <- dataset [, sortedNames ]
86
+
81
87
# possible data matrix?
82
88
if ((nrow(dataset ) != ncol(dataset )))
83
89
.quitAnalysis(gettext(" Input data does not seem to be a square matrix! Please check the format of the input data." ))
@@ -87,6 +93,7 @@ principalComponentAnalysisInternal <- function(jaspResults, dataset, options, ..
87
93
88
94
usedvars <- unlist(options [[" variables" ]])
89
95
var_idx <- match(usedvars , colnames(dataset ))
96
+
90
97
mat <- try(as.matrix(dataset [var_idx , var_idx ]))
91
98
if (inherits(mat , " try-error" ))
92
99
.quitAnalysis(gettext(" All cells must be numeric." ))
@@ -102,10 +109,11 @@ principalComponentAnalysisInternal <- function(jaspResults, dataset, options, ..
102
109
.quitAnalysis(" Not enough valid columns to run this analysis" )
103
110
}
104
111
}
112
+
113
+
105
114
return (mat )
106
115
}
107
116
108
-
109
117
.pcaCheckErrors <- function (dataset , options ) {
110
118
111
119
customChecksPCAEFA <- list (
0 commit comments