【3.2.2】reshape2包--数据变形
示例:
library(reshape2);
arc_genus_2<-read.table("arc_otu.csv",header=TRUE,sep="\t");
arc_otu.csv 数据存放位置http://pan.baidu.com/s/1mgFofuK
nn<-4;
aa<-arc_genus_2[,c(2:(nn+1),(nn+7))];
md<-melt(aa,id="genus");
ab<-dcast(md,genus~variable,sum);
md数据:
ab数据:
melt(data, id.vars,measure.vars,variable.name = "variable", ..., na.rm = FALSE,value.name = "value")
dcast(data, formula, fun.aggregate = NULL, ..., margins = NULL,
subset = NULL, fill = NULL, drop = TRUE,
value.var = guess_value(data))
acast(data, formula, fun.aggregate = NULL, ..., margins = NULL,
subset = NULL, fill = NULL, drop = TRUE,
value.var = guess_value(data))
参考资料:
R语言实战
这里是一个广告位,,感兴趣的都可以发邮件聊聊:tiehan@sina.cn
个人公众号,比较懒,很少更新,可以在上面提问题,如果回复不及时,可发邮件给我: tiehan@sina.cn
个人公众号,比较懒,很少更新,可以在上面提问题,如果回复不及时,可发邮件给我: tiehan@sina.cn