I am trying to plot the histogram for all the variables for the Wage dataset in order to understand their distribution. This I am trying to achieve by passing i column index as parameter inside a for loop in R, using following code.
library(ISLR);
library(ggplot2);
# load wage data
data(Wage)
par(mfrow=c(3,3))
for(i in 1:9){
ggplot(data=Wage)+geom_bar(aes(x=Wage[,i]))
}
But I am unable to produce any plot (this is error free). It is working if I individually provide the column numbers. I suspect the problem is somewhere in the par() or the for line. Kindly requesting to suggest.