比如原格式文件linear.xlsx是这样的:

reshape2: 将多列变量转换为行

VA1和VA2是两个变量,想把它变成以下格式:

reshape2: 将多列变量转换为行

则用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效果如下:

reshape2: 将多列变量转换为行

相关文章:

  • 2023-02-23
  • 2021-11-09
  • 2022-12-23
  • 2021-12-22
  • 2022-12-23
  • 2021-06-25
  • 2022-12-23
  • 2022-01-05
猜你喜欢
  • 2021-11-12
  • 2022-12-23
  • 2021-07-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案