reshape2: 将多列变量转换为行
比如原格式文件linear.xlsx是这样的:
VA1和VA2是两个变量,想把它变成以下格式:
则用reshape2
包转换:
library(openxlsx)
library(reshape2)
sw<-read.xlsx("E:/linear.xlsx", sheet = 1, colNames = TRUE)
da <- melt(sw,id=c("FID","IID"),measure=c("VA1","VA2"))
生成的文件da效果如下:
本文来自博客园,作者:橙子牛奶糖(陈文燕),转载请注明原文链接:https://www.cnblogs.com/chenwenyan/p/13565800.html