TuomoNieminen / Helsinki-Open-Data-Science

A DataCamp course for the University of Helsinki
https://www.datacamp.com/courses/helsinki-open-data-science
11 stars 10 forks source link

IODS-error-in-MCA-code-and-SOLUTION-by-Kimmo #9

Open avlehtim opened 2 years ago

avlehtim commented 2 years ago

From my own notes:


For some reason the MCA code in 5. Dimensionality reduction techniques did not work anymore. The problem is in the last exercise of the chapter.

I used some time (last year) for digging and testing, and found the solution!

The FactoMineR package had been updated (based on the GitHub commit history) last autumn:

https://github.com/cran/FactoMineR/commit/50569291277ad3e786f42dfecdeb900ed3988bc4

and there are some changed in the function plot.MCA:

https://github.com/cran/FactoMineR/blob/master/R/plot.MCA.R

I noticed that the argument graph.type is handled a bit carelessly (it might also be a new argument). Its values are "ggplot" or "classic". Somehow I focused on that and I noticed that this code of ours (which halts DataCamp!):

plot.MCA(mca, invisible=c("ind"), habillage = "quali")

will work perfectly, as soon as it is updated as follows:

plot.MCA(mca, invisible=c("ind"), habillage = "quali", graph.type = "classic")

I tested this both with plain R and in the DataCamp window of IODS.

So, it seems this would be a very small fix, with an immediate positive result.

Check also the instructions in the DataCamp exercise and the RStudio exercise.