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