安装tidyr
install.packages("tidyr")
library(tidyr)
重建数据框
读取数据,
b<-data.frame(country=c("A","B","C"),"1999"=paste(c(0.7,37,212),"K"),"2000"=paste(c(2,80,213),"K"))
gather(b,X1999,X2000,key = "year",value = "cases")
整理数据
x<-read.csv("doudou.txt")
drop_na(x,x2),删除整行
fill(x,x2),上下文蒙一个
replace_na(x,list(x2=2)),填进特定的数值
扩展数据
pin2<-data.frame(GeneId = rep("gene5",times=3),SampleName =paste("Sample",1:3,sep=""),Expression=c(14,19,18))
网友评论