wide to long multiple measures each time

后端 未结 5 1373
慢半拍i
慢半拍i 2020-12-01 06:45

I know the wide to long has been asked way too many times on here but I can\'t figure out how to turn the following into long format. Shoot I even asked one of the wide to

5条回答
  •  醉话见心
    2020-12-01 07:19

    Another way to approach the problem that requires very little code but would likely be slower,:

    DF.1 <- DF[, 1:2]
    DF.2 <- DF[, 3:6] 
    DF.3 <- DF[, 7:10]
    
    names(DF.2) <- names(DF.3) <- unlist(strsplit(names(DF.2), ".", fixed=T))[c(T,F)]
    time <- rep(1:2, each=nrow(DF.1))
    data.frame(rbind(DF.1, DF.1), time, rbind(DF.2, DF.3))
    

提交回复
热议问题