Search code examples
rdebuggingpca

FactoMineR PCA with factor variables


Here is a link to the data in R data format (so you can see that the factors are actually factors):

Vaccination Data 2016

Here is the code:

df %>%
   PCA(scale.unit = TRUE,
       quali.sup = 14, #the factor variables
       graph = T)

Aside from telling me that it replaced missing values with means (which I was happy to see), the above produces this:

argument is not numeric or logical: returning NA
argument is not numeric or logical: returning NA
argument is not numeric or logical: returning NA
argument is not numeric or logical: returning NA
argument is not numeric or logical: returning NA
argument is not numeric or logical: returning NA
Error in PCA(., scale.unit = TRUE, quali.sup = 14, graph = T) : 
    The following variables are not quantitative:  ins_stat_i
    The following variables are not quantitative:  c1r
    The following variables are not quantitative:  childnm
    The following variables are not quantitative:  state
    The following variables are not quantitative:  sex
    The following variables are not quantitative:  language

I'm confused. I didn't say they were quantitative. I said they were quali.sup types. Can you duplicate it? If so, what's the solution? Thanks, all.


Solution

  • Oh dear. It turns out that I mistyped. I should have said the quali.sum variables were 13:19 and I said they were 14. That was the problem.