0

I have this data frame

df <- data.frame(subjects = 12:23,
                 Why_are_you_not_happy = 
                   c(1,2,"1,2,5",5,1,2,"3,4",3,2,"1,5",3,4),
                 why_are_you_sad = 
                   c("1,2,3",1,2,3,"4,5,3",2,1,4,3,1,1,1))
df

that is coverted into this format

df1 <- df %>%
  separate(Why_are_you_not_happy,
           sep = ",", into = c("Why_are_you_not_happy_1",
                               "Why_are_you_not_happy_2",
                               "Why_are_you_not_happy_3")) %>%
  separate(why_are_you_sad,
           sep = ",", into = c("why_are_you_sad_1",
                               "why_are_you_sad_2",
                               "why_are_you_sad_3"))

when applying the MCA function we take all the columns except the first one

library(FactoMineR)
library(factoextra)
#> Loading required package: ggplot2

results <- MCA(df1[,2:7])

I decided to make quantiles of the individuals coord as follows :

quantile(results$ind$coord[,'Dim 1'])

and I want to add colors to the individuals groups based on their belongings to the first group between first quantile and second quantile, second group that is between second quantile and third quantile... etc.

Thanks.

Anas116
  • 797
  • 2
  • 9

0 Answers0