服务热线
178 0020 3020
直方图
library(ggplot2)
mydata<-read.csv("R2-2.1.csv")
ggplot(mydata,aes(x=bwt,fill=factor(mydata$smoke)))+geom_histogram(binwidth=400,colour="black",position="dodge")+ggtitle("R2-18")+xlab("birth weight")+scale_fill_discrete(h=c(0,200),c=400,name="Smoke",labels = c("no","yes"))
密度图
ggplot(diamonds, aes(x=price, color= color))+geom_line(stat = "density",size=0.5) +xlab("price")+ ggtitle("R2-18")+theme_bw()
附件