I'm trying to use correspondence analysis in R. It seems like the first argument of function "CA" in FactoMineR must be a contingency table. "dt" is a contingency table, but it returns that the variables are not quantitative.
One of the levels of X1 is empty, I dont know if this is a problem in Correspondence Analysis
library("FactoMineR")
tab1 <- table(as.factor(df$X1),as.factor(df$X2))
dt <- as.table(as.matrix(tab1))
res.ca <- CA(dt, graph = FALSE)
The output is:
Error in CA(tab1, graph = FALSE) :
The following variables are not quantitative: Var1
The following variables are not quantitative: Var2
You have to convert your
tab1to data frame usingas.data.frame.matrix(), before passing it toCAfunction.Sample Data: