服务热线
178 0020 3020
密度图
library(ggplot2)
ggplot(diamonds,aes(x=price,colour = color))+geom_line(stat = "density",size = 2)+ggtitle("R2-07")
直方图
> library(ggplot2)
Warning message:
程辑包‘ggplot2’是用R版本3.4.2 来建造的
> getwd()
[1] "C:/Users/Administrator/Desktop/R语言"
> a<-read.csv(file="R2-2.1.csv")
> a$smoke<-factor(a$smoke)
> ggplot()+geom_histogram(data=a,aes(x=bwt,fill=smoke),position="dodge",color="black",binwidth=400)+xlab("birth weight")+ggtitle("R2--07")+scale_fill_discrete(labels=c("no","yes"))
>
附件