rstudio中的彩色直方图变量

时间:2018-04-16 14:41:06

标签: r variables colors histogram

从此链接EXCEL FILE

我写了那段代码

library(ggplot2)

manze<-manze_ZAMBELLONI
manze$DAGE<-as.numeric(manze$DAGE)

ggplot(manze, aes(DAGE))+
  geom_histogram(col="black", aes(fill=RPRO), bins=20)+
  geom_density(aes(y=50*..count..), alpha=0.2)`

得到了那个漂亮的直方图:

histogram giving a view of the total amount of heifers in a dairy operation by age, and reproductive status represented by colour

所以问题是:出于几个原因,有时我更喜欢使用默认的Rstudio直方图,我想我知道该怎么做,除了我不知道如何根据生殖状态着色,所以&#39我正在得到什么

hist(manze$DAGE, breaks = 30, prob=T, col="grey") 
grid() 
lines(density(manze$DAGE), col="blue", lwd=3)
axis(side=1, at=seq(0,900,50))

same histogram by Rstudio default

因此;如何通过生殖状态为第二种语法添加顺序?

非常感谢和亲切的问候。

0 个答案:

没有答案