服务热线
178 0020 3020
Task1
library(ggplot2)
data<- ToothGrowth
write.table (data, file ="data.csv", sep =",", row.names =FALSE, col.names =TRUE, quote =TRUE)
data1<-read.csv("R2-10.csv")
p<-ggplot(data1,aes(data1,x=dose,y=len,color=supp))+geom_line(size=1.5,position=pd)+geom_point(size=3,position=pd)+
geom_errorbar(aes(ymin=len-sd,ymax=len+sd,color=supp),size=1.2,position=pd)+ggtitle("R2-33")+xlab("Dose(mg)")+ylab("Tooth length")+
scale_color_hue(name="Supplement type",breaks=c("OJ","VC"),labels=c("Orange juice","Ascorbic acid"))+
theme_bw()+theme(legend.justification=c(1,0),legend.position=c(1,0))
P
Task2
library(ggplot2)
data2<-midwest
head(data2)
p<- ggplot(data2,aes(x=area,y=poptotal))+geom_point(aes(col=state,size=popdensity))+
geom_smooth(method="loess",se=F)+xlim(c(0,0.1))+ylim(c(0,500000))+xlab("Area")+ylab("Population")+labs(subtitle="Area vs Population",title="R2-33",caption="Source:midwest")
p+theme_bw()
Task3
install.packages("RColorBrewer")
library(RColorBrewer)
library(ggplot2)
data3<- read.csv("Task3.csv")
mymatrix=data.matrix(data3[,c(-1)])
row.names(mymatrix)=data3[,1]
heatmap(mymatrix,Rowv=NA,Colv=NA,col=brewer.pal(9,"Blues"),scale="column",main="R2-33")
附件