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