id是病人id,randomid是随机号,hb,wc是检查项目,hbi,wci是检查项目的临床意义
现要求把数据变成四列,即病人id,随机号,检查项目,项目的临床意义
rm(list=ls()) data <- read.table('clipboard',header = T) install.packages("tidyverse") library(tidyverse) DATA1 <- gather(data,key="sample",value="xx",c(3,5)) DATA1$MEANING[DATA1$sample=="hb"] <- DATA1$hbi DATA1$MEANING[DATA1$sample=="wc"] <- DATA1$wci DATA1 <- DATA1[,c(1,2,5,6,7)]