http://www.cookbook-r.com/Graphs/Plotting_distributions_(ggplot2)/
df <- data.frame(cond = factor( rep(c("A","B"), each=200)),
+ rating = c(rnorm(200), rnorm(200, mean=.8)))
> qplot(df$rating, binwidth=.5)
> ggplot(df, aes(x=rating)) + geom_histogram(binwidth=.5)
> ggplot(df, aes(x=rating)) + geom_histogram(binwidth=.5, colour="black", fill="white")
> ggplot(df, aes(x=rating)) + geom_density()
> ggplot(df, aes(x=rating)) +
+ geom_histogram(aes(y=..density..), # Histogram with density instead of count on y-axis
+ binwidth=.5,
+ colour="black", fill="white") +
+ geom_density(alpha=.2, fill="#FF6666") # Overlay with transparent density plot
> ggplot(df, aes(x=rating)) + geom_histogram(binwidth=.5, colour="black", fill="white") +
+ facet_grid(cond ~ .) +
+ geom_vline(data=cdf, aes(xintercept=rating.mean),
+ linetype="dashed", size=1, colour="red")
'Data Analytics' 카테고리의 다른 글
R 자료형 (0) | 2013.12.22 |
---|---|
data.frame(x=xvar, y=yvar, z=zvar) (0) | 2013.12.22 |
QL WITH BIGDATA (0) | 2013.12.15 |
R 기본 예제 돌려보기 20131212 (0) | 2013.12.13 |
[책] 데이터는 알고 있다 데이터가 만드는 세상 BIG DATA - 2 (0) | 2013.07.03 |