Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm trying to run an MCA on a datatable using FactoMineR. It contains only 0/1 numerical columns, and its size is 200.000 * 20.

require(FactoMineR)
result <- MCA(data[, colnames, with=F], ncp = 3)

I get the following error :

Error in which(unlist(lapply(listModa, is.numeric))) : argument to 'which' is not logical

I didn't really know what to do with this error. Then I tried to turn every column to character, and everything worked. I thought it could be useful to someone else, and that maybe someone would be able to explain the error to me ;)

Cheers

like image 287
VeilleData Avatar asked Dec 14 '15 11:12

VeilleData


2 Answers

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])
}
like image 164
marques Avatar answered Nov 16 '22 03:11

marques


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
like image 32
krlmlr Avatar answered Nov 16 '22 02:11

krlmlr