Why ggcorplot doesn't show every level of a factor feature?

Viewed 100

I'm trying to plot the correlation matrix of a dataframe, I've changed 2 factor features reducing their number of class from 6 to 3 and from 4 to 2, so i've created 2 other features.

dati<-read.csv("datiReport.csv", header = TRUE, sep=",",stringsAsFactors=TRUE)
dati <-as_tibble(dati)
str(dati)
dati_modificati <- dati %>% 
  mutate(Professione = case_when(
         Profess%in% c("Lib.prof", "Imprenditore") ~ "Autonomi",
         Profess%in% c("Impiegato","Operaio") ~ "Dipendenti",
         Profess%in% c("Pensionato", "Studente") ~ "Inattivi"),
         Area=case_when(AreaG %in% c("Centro", "Nord") ~ "Centro_Nord",
                 AreaG %in% c("Sud", "Isole") ~ "Sud_e_Isole"))

Then I've removed some variables and I've also removed those variable which I've just transformed:

drop <- c("Profess","AreaG","NAnnullYear","NRimbYear","NArtVis","NAccMonth","X","NresiYear")
dati_modificati <- dati_modificati[,!(names(dati_modificati) %in% drop)]

But When I plot the correlation matrix in this way :

model.matrix(~0+., data=dati_modificati) %>% 
  cor(use="pairwise.complete.obs") %>% 
  ggcorrplot(show.diag = F, type="lower", lab=TRUE, lab_size=2)

In the axes appear only a subset of variables. I apologize in advance if it is a stupid question, but I don't know how to solve it, does ggcorplot limit the number of variables present in the axes?

0 Answers
Related