1

I'm trying to run an MCA on a data set using FactoMineR, and keep getting this error despite that fact that my data is Y/N (ie. not numerical binary 1/0):

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

I've read that R categorical data is related to factor type, so even if you have characters you could get this error. But I don't know what 'factor type' means, or how I can change that. I have been trying to use this code:

require(FactoMineR)
head(mydata)
cats = apply(mydata, 2, function(x) nlevels(as.factor(x)))
mca1 = MCA(mydata, graph = FALSE)

I'm a complete R novice and don't understand a lot of the coding language but really want to learn! Any help would be much appreciated as this is for a Masters project

> dput(head(mydata))
structure(list(Icthyosaur = c("Y", "Y", "N", "N", "Y", "N"), 
Plesiosaur = c("N", "N", "Y", "N", "N", "N"), Pliosaur = c("N", 
"N", "N", "Y", "N", "N"), Crocodile = c("N", "N", "N", "N", 
"N", "Y"), `Bite mark` = c("Y", "Y", "N", "N", "Y", "Y"), 
`Mechanical stress` = c("N", "N", "Y", "N", "N", "N"), `Erosive arthrosis` = c("N", 
"N", "N", "Y", "N", "N"), Fracture = c("N", "N", "N", "N", 
"N", "N"), Exostoses = c("N", "N", "N", "N", "N", "N"), `Vertebral Fusion ` = c("N", 
"N", "N", "N", "N", "N"), Cranial = c("Y", "N", "N", "Y", 
"N", "Y"), Appendicular = c("N", "Y", "N", "N", "N", "N"), 
Axial = c("N", "N", "Y", "N", "Y", "N"), Pelvic = c("N", 
"N", "N", "N", "N", "N"), Pectoral = c("N", "N", "N", "N", 
"N", "N")), .Names = c("Icthyosaur", "Plesiosaur", "Pliosaur", 
"Crocodile", "Bite mark", "Mechanical stress", "Erosive arthrosis", 
"Fracture", "Exostoses", "Vertebral Fusion ", "Cranial", "Appendicular", 
"Axial", "Pelvic", "Pectoral"), call = "XLGetRange(file = \"C:\\\\Users\\\\Ally\\\\Documents\\\\MSci Project\\\\ImportR.xlsx\", sheet = \"Sheet1\",\n     range = c(\"A1:O124\"),\n     as.data.frame = TRUE, header = TRUE, stringsAsFactors = FALSE)", row.names = c(NA, 
6L), class = "data.frame")

> mca1 = MCA(mydata, graph = FALSE)
Error in which(unlist(lapply(listModa, is.numeric))) : 
  argument to 'which' is not logical

> traceback()
3: which(unlist(lapply(listModa, is.numeric)))
2: tab.disjonctif(X[, act, drop = FALSE])
1: MCA(mydata, graph = FALSE)
A.R.I
  • 11
  • 4
  • [This](http://stackoverflow.com/questions/34266186/what-does-argument-to-which-is-not-logical-mean-in-factominer-mca) should help you. – agstudy Dec 16 '16 at 23:11
  • Thanks for the recommendation. I had seen that page, and was confused as to what the best answer was doing. Do they mean this: – A.R.I Dec 16 '16 at 23:26
  • traceback(mca1 = MCA(mydata, graph = FALSE)) – A.R.I Dec 16 '16 at 23:26
  • The less-rated answers to that question suggest converting the data into factors; I'm supposing this isn't the best option? – A.R.I Dec 16 '16 at 23:34
  • you should provide and example of data to easily reproduce your problem. For example , edit your question and please add the output of `dput(head(mydata))`? – agstudy Dec 16 '16 at 23:51
  • very sorry, moved back home to rural area without Wi-Fi. – A.R.I Dec 23 '16 at 13:27
  • I've now edited the question – A.R.I Dec 23 '16 at 13:30

0 Answers0