服务热线
178 0020 3020
library(ggplot2)
R2_04_1 <- read.csv("/users/taowang/documents/R/R2/R2-2.1/R2-2.1.csv",header = T)
png("/Users/taowang/documents/R/R2/R2-2.1/R2-2.1.png")
ggplot(data = R2_04_1,aes(x= bwt,fill= factor(R2_04_1$smoke)))+
geom_histogram(binwidth = 400,position = "dodge",,color = "black")+
ggtitle("R2-04")+
xlab("birth weight")+
ylab("count")+
scale_fill_discrete(labels = c("NO","YES"), name = "Smoke")
dev.off()
png("/Users/taowang/documents/R/R2/R2-2.1/R2-2.2.png")
ggplot(data = diamonds, aes(x = carat, color = color))+
geom_line(stat = "density",size = 0.3)+
ggtitle("R2-04")+
xlab("carat")+
ylab("density")+
theme_bw()
dev.off()
附件