I am trying to store in a list some plots built through this code:
list7 = NULL
for (col in colnames(mtcars)[1:2]) {
list7[[col]] <-
ggplot(mtcars, aes(x= mtcars[,col])) +
geom_histogram(aes(y=..density..), color="darkblue", fill="lightblue")+
geom_density(alpha=.2, fill="#FF6666") +
ggtitle(paste0(col, ' score distribution')) +
xlab(col) +
theme_classic()
}
I cannot understand why despite I have the right information about the axis names, titles and list names, the plots represent similar results.
Could anyone help me to figure out why? Thanks