服务热线
178 0020 3020
rm(list = ls())
work.dir <- "D:/R Learning/exercise/R2-02/"
setwd(work.dir)
getwd() #check working directory
data2_1 <- read.csv("R2-2.1.csv", header=TRUE)
ggplot(data2_1,aes(x = bwt,fill = factor(data2_1$smoke))) + geom_histogram(binwidth = 400,position = "dodge", color= "black") +scale_fill_brewer(palette = "default", labels = c("NO","YES"),name="Smoke") + labs(x = "birth weight", y="count",title = "R2-10")
ggplot(diamonds,aes(x=price,colour = color))+geom_line(stat = "density",size = 0.5)+labs(x = "price", y="density",title = "R2-10")+theme_bw()
PS:由于在文中插入图片一直失败,所以将图片放在附件了。
附件