What does "argument to 'which' is not logical" mean in FactoMineR MCA?

Are the classes of your variables character or factor?I was having this problem. My solution was to change al variables to factor.

#my data.frame was "aux.da"
i=0
while(i < ncol(aux.da)){
  i=i+1  aux.da[,i] = as.factor(aux.da[,i])
}

I just started to learn R yesterday, but the error comes from the fact that the MCA is for categorical data, so that's why your data cannot be numeric. Then to be more precise, before the MCA a "tableau disjonctif" (sorry i don't know the word in english : Complete disjunctive matrix) is created. So FactomineR is using this function :

https://github.com/cran/FactoMineR/blob/master/R/tab.disjonctif.R

Where i think it's looking for categorical values that can be matched to a numerical value (like Y = 1, N = 0).

For others ; be careful : for R categorical data is related to factor type, so even if you have characters you could get this error.


It's difficult to tell without further input, but what you can do is:

  • Find the function where the error occurred (via traceback()),
  • Set a breakpoint and debug it:

    trace(tab.disjonctif, browser)
    

I did the following (offline) to find the name of tab.disjonctif:

  • Found the package on the CRAN mirror on GitHub
  • Search for that particular expression that gives the error