服务热线
178 0020 3020
setwd("F:\\Doctor\\R语言学习\\互助小组\\第10期作业")
#Figure 10.1
data<-read.csv("10-1.csv",header=TRUE)
library(ggplot2)
library(plyr)
mytheme_10 <- theme_bw() +
theme(panel.grid = element_blank())
cdata <- ddply(data, c("Group","Time"),summarise,mean = mean(value),sd = sd(value))
ggplot(cdata, aes(Time,mean,group=Group,color=Group)) + ggtitle("R2-20") +
geom_line()+
geom_point(size=3,aes(shape=Group))+
geom_errorbar(aes(ymin=mean-sd, ymax=mean+sd),width=0.1)+
mytheme_10
#Figure 10.2
library(ggplot2)
options(scipen=999)
theme_set(mytheme_10)
data("midwest", package = "ggplot2")
ggplot(midwest, aes(x=area, y=poptotal)) +
geom_point(aes(col=state, size=popdensity)) +
geom_smooth(method="loess", se=T) +
scale_color_brewer(palette = "Spectral")+
xlim(c(0, 0.1)) +
ylim(c(0, 500000)) +
labs(subtitle="Area Vs Population",
y="Population", x="Area",title="R2-20",caption = "Source: midwest")
#Figure 10.3
library(reshape2)
library(ggplot2)
library(plyr)
library(scales)
data_heatmap<- read.csv("task3.csv")
data_m <- melt(data_heatmap, id.vars=c("Name"))
data_m <- ddply(data_m, .(variable), transform, label = rescale(value))
ggplot(data_m, aes(x=variable,y=Name)) +
geom_tile(aes(fill=label)) +
scale_fill_gradient(low = "white", high = "steelblue") +
xlab("Type") + theme_bw() + ggtitle("R2-20")


附件