I have a dataframe called test2 and I would like to make multiple plots or subplots which have the same x axis that is month variable and other variables in this dataframe, each as y axis in a plot. My codes is below and it gives me error message... Can you help see how to fix it? Thank in advance.
plot_analysis <- list()
col<-names(test2)[!names(test2)%in%"month"]
for(i in col){
print(i)
plot_analysis[i] <- ggplot(data=test2, aes(month))+
geom_bar(aes(fill=as.factor(col), position="fill")) +
xlab("month") + ylab("") + scale_y_continuous(labels=scales::percent) + scale_x_discrete(limits = month.abb)
}
Warning messages: 1: Ignoring unknown aesthetics: position 2: In plot_analysis[i] <- ggplot(data = test2, aes(month)) + geom_bar(aes(fill = as.factor(col), : number of items to replace is not a multiple of replacement length
{{col}}
– Richard Telford