Lecture4_my-script-with-R_reshape

Jimmyjmzeng1314@outlook.com

Keywords: reshape2/melt/dcast

library(reshape2)

d=matrix(abs(rnorm(120)),ncol = 6)

rownames(d)=LETTERS[1:20]

colnames(d)=LETTERS[21:26]

dat=melt(d)

rownames(tmp)=tmp[,1]

tmp=tmp[,-1]

reshapeR base/stats的函数,主要用于数据框长格式和宽格式之间的转换。reshape函数的参数很多,不容易记,牛人Hadley Wickham搞出reshapereshape2包以后这个函数几乎被人遗忘

useful links : http://developer.51cto.com/art/201305/396615.htm