r - Using a loop in ggplot2 -
i trying create multiple boxplots in ggplot. need split continuous variables nominal variable (school). want omit single na's in data-frame dataso. want create boxplot every column , have name of column label. when use following code don't error message, no plots generated. ideas?
for(i in 1:length(dataso)) { boxplot <- ggplot(na.omit (dataso), aes(school,i)) + geom_boxplot() + labs(x = "school", y = names(dataso[i])) }
i able generate 1 boxplot using code:
box2 <- ggplot(na.omit (dataso), aes(school, soirglobal)) box2 + geom_boxplot() + labs(x = "school", y = "soirglobal")
i great boxplots 9 other variables in dataso
dataso <- subset(datafull, age >= 18, select=c(age, school, race, soir1:soir9))
Comments
Post a Comment