第6线图热力图数据展现_第1页
第6线图热力图数据展现_第2页
第6线图热力图数据展现_第3页
第6线图热力图数据展现_第4页
第6线图热力图数据展现_第5页
已阅读5页,还剩29页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、R语言进阶数据展现 第6周2012.12.13DATAGURU专业数据分析法律【】本和幻灯片为炼数网络课程的教学资料,所有资料只能在课程内使用,不得在课程以外范围散播,违者将可能被责任。法律和课程详情炼数培训http:2012.12.132DATAGURU专业数据分析箱型图使用第七周数据air-read.csv(airpollution.csv)boxplot(air,las=1)2012.12.133DATAGURU专业数据分析收窄箱体宽度boxplot(air,boxwex=0.2,las=1)2012.12.134DATAGURU专业数据分析指定箱体的宽度boxplot(air,widt

2、h=c(1,2)2012.12.135DATAGURU专业数据分析分组ms-read.csv(ms.csv)boxplot(CuSource,data=ms,main=Summary of Copper (Cu) concentrations bySite)boxplot(CuSource*Expt,data=ms,main=Summary of Copper (Cu) concentrations bySite)2012.12.136DATAGURU专业数据分析观测值数量决定箱体宽度boxplot(Cu Source, data =ms,varwidth=TRUE,main=Summary

3、of Copperconcentrations by Site)2012.12.137DATAGURU专业数据分析带notch的箱型图boxplot(Cu Source, data = mvarwidth=TRUE,notch=TRUE,main=Summary of Copper concentrations by Site)s,2012.12.138DATAGURU专业数据分析排除离群值boxplot(ms,-1,outline=FALSE,main=Summary of mconcentrations by Site n(without outliers)2012.12.139DATAG

4、URU专业数据分析水平放置boxplot(ms,-1,horizontal=TRUE,las=1,main=Summary of m concentrations by Site)2012.12.1310DATAGURU专业数据分析改变箱型风格boxplot(ms,-1,border = white,col = black,boxwex = 0.3,medlwd=1, whiskcol=black,staplecol=black, outcol=red,cex=0.3,outpch=19,main=Summary of mconcentrations by Site)grid(nx=NA,ny

5、=NULL,col=gray,lty=dashed)2012.12.1311DATAGURU专业数据分析改变箱型风格2012.12.1312DATAGURU专业数据分析延长须线boxplot(ms,-1,range=0,border = white,col =black, boxwex =0.3,medlwd=1,whiskcol=black,staplecol=black,outcol=red,cex=0.3,outpch=19, main=Summary of mconcentrations by Site n(range=0)2012.12.1313DATAGURU专业数据分析显示观测数

6、量b-boxplot(ms,-1,xaxt=n,border = white,col = black,boxwex = 0.3,medlwd=1,whiskcol=black, staplecol=black,outcol=red,cex=0.3,outpch=19,main=Summary of mconcentrations by Site)axis(side=1,at=1:length(b$names),labels=paste(b$names,n(n=,b$n,),sep=), mgp=c(3,2,0)2012.12.1314DATAGURU专业数据分析显示观测数量2012.12.13

7、15DATAGURU专业数据分析使用gplot包install.packages(gplots)library(gplots)boxplot.n(ms,-1,border = white,col =black,boxwex = 0.3, medlwd=1,whiskcol=black,staplecol=black,outcol=red,cex=0.3,outpch=19, main=Summary of mconcentrations by Site)2012.12.1316DATAGURU专业数据分析分割数据cuts-c(0,40,80)Y-split(x=ms$Cu, f=findInt

8、erval(ms$Cu, cuts)boxplot(Y,xaxt=n,border = white,col = black,boxwex = 0.3, medlwd=1,whiskcol=black,staplecol=black, outcol=red,cex=0.3,outpch=19, main=Summary of Copper concentrations, xlab=Concentration ranges,las=1) axis(1,at=1:4,labels=c(Below 0,0 to 40,40 to 80,Above 80),lwd=0,lwd.ticks=1,col=g

9、ray)2012.12.1317DATAGURU专业数据分析分割数据2012.12.1318DATAGURU专业数据分析函数化boxplot.cuts-function(y,cuts,.) Y-split(ms$Cu, f=findInterval(y, cuts)b-boxplot(Y,xaxt=n,border = white,col = black,boxwex = 0.3, medlwd=1,whiskcol=black,staplecol=black, outcol=red,cex=0.3,outpch=19, main=Summary of Copper concentration

10、s, xlab=Concentration ranges,las=1,.)clabels-paste(Below,cuts1) for(k in 1:(length(cuts)-1) clabels-c(clabels, paste(as.character(cutsk), to, as.character(cutsk+1)clabels40)2012.12.1321DATAGURU专业数据分析另一个函数boxplot.cuts-function(y,cuts) f=cut(y, c(min(y!is.na(y),cuts,max(y!is.na(y), ordered_results=TRU

11、E);Y-split(y, f=f)b-boxplot(Y,xaxt=n,border = white,col = black,boxwex = 0.3, medlwd=1,whiskcol=black,staplecol=black, outcol=red,cex=0.3,outpch=19, main=Summary of Copper concentrations, xlab=Concentration ranges,las=1)clabels = as.character(levels(f) axis(1,at=1:length(clabels), labels=clabels,lwd

12、=0,lwd.ticks=1,col=gray)2012.12.1322DATAGURU专业数据分析结果boxplot.cuts(ms$Cu,c(0,40,80)2012.12.1323DATAGURU专业数据分析热力图使用第八章数据sales-read.csv(sales.csv)install.packages(RColorBrewer)library(RColorBrewer)rownames(sales)-sales,1sales-sales,-1data_matrix-data.mpal=brewer.pal(7,YlOrRd) atrix(sales)breaks-seq(3000

13、,12000,1500)2012.12.1324DATAGURU专业数据分析代码layout(matrix(data=c(1,2), nrow=1, ncol=2), widths=c(8,1),heights=c(1,1)#Set margins for the heatmappar(mar = c(5,10,4,2),oma=c(0.2,0.2,0.2,0.2),mex=0.5)image(x=1:nrow(data_matrix),y=1:ncol(data_matrix), z=data_matrix,axes=FALSE,xlab=Month, ylab=,col=pal1:(len

14、gth(breaks)-1), breaks=breaks,main=Sales Heat Map) axis(1,at=1:nrow(data_matrix),labels=rownames(data_matrix), col=white,las=1) axis(2,at=1:ncol(data_matrix),labels=colnames(data_matrix), col=white,las=1)abline(h=c(1:ncol(data_matrix)+0.5,v=c(1:nrow(data_matrix)+0.5, col=white,lwd=2,xpd=FALSE) break

15、s2-breaks-length(breaks)2012.12.1325DATAGURU专业数据分析代码par(mar = c(5,1,4,7)image(x=1, y=0:length(breaks2),z=t(matrix(breaks2)*1.001,col=pal1:length(breaks)-1,axes=FALSE,breaks=breaks, xlab=, ylab=,xaxt=n)axis(4,at=0:(length(breaks2)-1), labels=breaks2, col=white, las=1)abline(h=c(1:length(breaks2),col=

16、white,lwd=2,xpd=F)2012.12.1326DATAGURU专业数据分析结果2012.12.1327DATAGURU专业数据分析相关热力图genes-read.csv(genes.csv)rownames(genes)-genes,1data_matrix-data.matrix(genes,-1)pal=heat.colors(5) breaks-seq(0,1,0.2)layout(matrix(data=c(1,2), nrow=1, ncol=2), widths=c(8,1),heights=c(1,1)par(mar = c(3,7,12,2),oma=c(0.2,

17、0.2,0.2,0.2),mex=0.5)image(x=1:nrow(data_matrix),y=1:ncol(data_matrix), z=data_matrix,xlab=,ylab=,breaks=breaks,col=pal,axes=FALSE)2012.12.1328DATAGURU专业数据分析相关热力图text(x=1:nrow(data_matrix)+0.75, y=par(usr)4 + 1.25,srt = 45, adj = 1, labels = rownames(data_matrix), xpd = TRUE)axis(2,at=1:ncol(data_ma

18、trix),labels=colnames(data_matrix), col=white,las=1) abline(h=c(1:ncol(data_matrix)+0.5,v=c(1:nrow(data_matrix)+0.5, col=white,lwd=2,xpd=F)title(Correlation between genes,line=8,adj=0) breaks2-breaks-length(breaks)# Color Scalepar(mar = c(25,1,25,7)image(x=1, y=0:length(breaks2),z=t(matrix(breaks2)*

19、1.001, col=pal1:length(breaks)-1,axes=FALSE, breaks=breaks,xlab=,ylab=,xaxt=n)axis(4,at=0:(length(breaks2),labels=breaks,col=white,las=1) abline(h=c(1:length(breaks2),col=white,lwd=2,xpd=F)2012.12.1329DATAGURU专业数据分析相关热力图2012.12.1330DATAGURU专业数据分析展现多变量数据rownames(nba)-nba,1data_matrix-t(scale(data.mat

20、rix(nba,-1) pal=brewer.pal(6,Blues)statnames-c(Games Played, Minutes Played, Total Points,Field Goals Made, Field Goals Attempted, Field Goal Percentage, Free Throws Made,Free Throws Attempted, Free Throw Percentage, Three Pointers Made, Three Pointers Attempted, Three Point Percentage, Offensive Re

21、bounds,Defensive Rebounds, Total Rebounds, Assists, Steals, Blocks, Turnovers, Fouls)par(mar = c(3,14,19,2),oma=c(0.2,0.2,0.2,0.2),mex=0.5)#Heat map image(x=1:nrow(data_matrix),y=1:ncol(data_matrix), z=data_matrix,xlab=,ylab=,col=pal,axes=FALSE)2012.12.1331DATAGURU专业数据分析展现多变量数据#X axis labelstext(1:nrow(data_matrix), par(usr)4 + 1, srt = 45, ad

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论