R2-36 第十期 综合案例

范志敏 2018-01-08 21:38:05 阅读: 1078

setwd("E:/bioinformatics/fanzhimin")

tg <- ToothGrowth

library(ggplot2)

summarySE <- function(data=NULL, measurevar, groupvars=NULL, na.rm=FALSE,

+                       conf.interval=.95, .drop=TRUE) {

+     library(plyr)

+ length2 <- function (x, na.rm=FALSE) {

+     if (na.rm) sum(!is.na(x))

+     else       length(x)

+ }

+ datac <- ddply(data, groupvars, .drop=.drop,

+                .fun = function(xx, col) {

+                    c(N    = length2(xx[[col]], na.rm=na.rm),

+                      mean = mean   (xx[[col]], na.rm=na.rm),

+                      sd   = sd     (xx[[col]], na.rm=na.rm)

+                    )

+                },

+                measurevar

+ )

+ datac <- plyr::rename(datac, c("mean" = measurevar))

+ datac$se <- datac$sd / sqrt(datac$N) 

+ ciMult <- qt(conf.interval/2 + .5, datac$N-1)

+ datac$ci <- datac$se * ciMult

+ return(datac)

+ }

tgc <- summarySE(tg, measurevar="len", groupvars=c("supp","dose"))

ggplot(tgc, aes(x=dose, y=len, colour=supp))+geom_point()+geom_line()+ geom_errorbar(aes(ymin=len-se, ymax=len+se), width=.1)+ggtitle("R2-36")



library(ggplot2)

D<-ggplot(midwest,aes(x=area,y=poptotal))+geom_point(aes(col=state,size=popdensity))+geom_smooth(method='loess')+xlim(c(0,0.1))+ylim(c(0,500000))+labs(title="R2-36")

mytheme<- theme(panel.grid = element_blank(), panel.background=element_blank(),axis.text=element_blank(),axis.ticks = element_blank())+theme(legend.position = "bottom")

D+mytheme



install.packages("RColorBrewer")

library(RColorBrewer)

 data1 <- read.csv("task3.csv", header = TRUE)

data1 <- data1[order(data1$PTS),]

row.names(data1) <- data1$Name

 data1 <- data1[,2:20]

 data2 <- data.matrix(data1)

heatmap(data2, Rowv=NA, Colv=NA, col = brewer.pal(9, "Blues"), scale="column", margins=c(5,10))


 
邀请讨论

附件

{{f.title}} 大小 {{f.file_size}} 下载 {{f.count_download}} 金币 {{f.count_gold}}
{{item.nick_name}} 受邀请回答 {{item.create_time}}
{{item.refer_comment.nick_name}} {{item.refer_comment.create_time}}

附件

{{f.title}} 大小 {{f.file_size}} 下载 {{f.count_download}} 金币 {{f.count_gold}}
切换到完整回复 发送回复
赞({{item.count_zan}}) 踩({{item.count_cai}}) 删除 回复 关闭
科研狗©2015-2024 科研好助手,京ICP备20005780号-1 建议意见

服务热线

178 0020 3020

微信服务号