服务热线
178 0020 3020
直方图:
datahis<-read.table("R2-2.1.csv",header = T,sep = ",")
library(ggplot2)
ggplot(datahis,aes(x=bwt,fill=factor(datahis$smoke)))+geom_histogram(color="black",binwidth = 400,position = "dodge")+ggtitle("R2-12")+xlab("birth weight")+scale_fill_discrete(name="smoke",labels=c("No","Yes"))
密度图:
library(ggplot2)
ggplot(diamonds,aes(x=carat,color=color))+geom_line(stat = "density")+ggtitle("R2-12")+xlab("price")+theme_bw()
附件