What does “argument” that “illogical” mean in FactoMineR MCA?

I am trying to run MCA on a datatable using FactoMineR. It contains only numeric columns 0/1, and its size is 200,000 * 20.

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

I get the following error:

An error in which (unlist (lapply (listModa, is.numeric))): the argument "which" is illogical

I really did not know what to do with this error. Then I tried to turn each column into a character , and it worked. I thought it might be useful to someone else, and that maybe someone could explain this error to me;)

Greetings

+5
source share
4 answers

It's hard to say without further input, but you can do this:

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

     trace(tab.disjonctif, browser) 

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

  • Found package on CRAN mirror on GitHub
  • Search for this particular expression that gives an error
+1
source

Are your variable classes a symbol or factor? I had this problem. My solution was to change al variables to a 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]) } 
+1
source

I just started learning R yesterday, but the error comes from the fact that the MCA is for categorical data , so why your data cannot be numeric. Then, to be more precise, before the MCA is “tableau disjonctif” (sorry, I don't know the words in English: full disjunctive matrix). Therefore FactomineR uses this function:

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

Where I think he is looking for categorical values ​​that can be matched with a numerical value (e.g. Y = 1, N = 0).

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

0
source

The same thing as the problem, as well as changing the factor, did not solve my answer , because I added each variable as an additional one .

First, I converted all the numerical data into a coefficient:

 Xfac = factor(X[,1], ordered = TRUE) for (i in 2:29){ tfac = factor(X[,i], ordered = TRUE) Xfac = data.frame(Xfac, tfac) } colnames(Xfac)=labels(X[1,]) 

However, this will not work. But my second problem was that I included EVERY factor as an additional variable! So:

 MCA(Xfac, quanti.sup = c(1:29), graph=TRUE) MCA(Xfac, quali.sup = c(1:29), graph=TRUE) 

Generates the same error, but this works:

 MCA(Xfac, graph=TRUE) 

Not converting data into factors also created a problem.

I posted the same answer in a related topic: fooobar.com/questions/1238117 / ...

-1
source

Source: https://habr.com/ru/post/1238115/


All Articles