Browse code

Update rankingDifferentMeans.R

Add flag for unique categorical

Ellis Patrick authored on 23/08/2022 21:22:56 • GitHub committed on 23/08/2022 21:22:56
Showing 1 changed files

... ...
@@ -8,7 +8,9 @@ differentMeansRanking <- function(measurementsTrain, classesTrain, verbose = 3)
8 8
   categorical <- sapply(measurementsTrain, class) %in% c("character", "factor")
9 9
   if(any(categorical)){
10 10
      pValues[categorical] <- sapply(which(categorical), function(featureIndex){
11
-      chisq.test(measurementsTrain[, featureIndex], classesTrain)$p.value
11
+       pval <- 1
12
+      if(length(unique(measurementsTrain[, featureIndex])>1)) pval <- chisq.test(measurementsTrain[, featureIndex], classesTrain)$p.value
13
+       pval
12 14
     })
13 15
   }
14 16