Recently I was looking around to find a quick way to create a long data frame out of a wide data frame containing patient data with multiple measurements per patient (let's say a heart rate, blood pressure, and saturation score for up to five days). While googling around I had expected to find numerous solutions from the tidyverse and/or the reshape2 package. However, I actual found this gem from base-R.
Now I cannot let go of trying to find an equally nice "one-liner" using one or more of the packages in the tidyverse and/or reshape2. So far, nothing as nice comes up and I'd appreciate a hint. Note that this question is explicitly about a pretty/neat, clever solution rather than finding the actual solution.
Data from linked post:
id <- paste('x', "1.", 1:10, sep="")
set.seed(10)
DF <- data.frame(id, trt=sample(c('cnt', 'tr'), 10, T), work.T1=runif(10),
play.T1=runif(10), talk.T1=runif(10), total.T1=runif(10),
work.T2=runif(10), play.T2=runif(10), talk.T2=runif(10),
total.T2=runif(10))