r - Graphing distribution of independent variable for any given dataset -
i looking automate process of exploratory data analysis , graph distribution (using line plots, histograms, density curves, etc.) of input variables. code stands, getting 4 blank graphics windows. doing incorrectly? if there better approach, open well.
mydata <- read.csv("http://www.ats.ucla.edu/stat/data/binary.csv") (i in names(mydata)){ qplot(data=mydata,i,geom="bar", fill="admit") dev.new() }
this situation looks 1 aes_string
come in handy (along addition of print
around call ggplot
). found this post showing how use aes_string
ggplot
inside loop.
so this:
mydata$admit = factor(mydata$admit) for(i in names(mydata)) { print(ggplot(mydata) + geom_bar(aes_string(x = i, fill = "admit"))) }
i'm working in rstudio have skipped dev.new
part of code. found needed convert admit
factor, well.
Comments
Post a Comment