[Daily-R] Beginning R 第五章练习

 

Ex1: Examine the orchis2 data object. Here you see a two-column data frame with a response variable (flower) and a predictor variable (site). Produce a histogram for the sprayed site. Now overlay a density plot.

1 ggplot(df, aes(x=value)) + geom_histogram(binwidth=.8, colour="black", fill="grey") + facet_grid(site ~ .)+ggtitle("Histogram for each site status")+xlab('Flower Number') + ylab('Count')+theme_bw()
with(orchis2, hist(orchis2$flower[orchis2$site=="sprayed"]))
hist(orchis2$flower[orchis2$site=="sprayed"])

 

 

 

 

 

 

 

 

 

posted @ 2012-12-11 16:56  Puriney  阅读(169)  评论(0编辑  收藏  举报