The following problem can be considered as a “two-column width conversion”, and there are several methods available for its classical solution: from base::reshape (horror) to reshape2 . For a case with two groups, joining a simple subgroup works best.
Is it possible to reformulate the connection within the dplyr piping dplyr ? The example below is a little silly, but I need a connection in a longer chain of channels, which I do not want to break.
library(dplyr) d = data.frame(subject= rep(1:5,each=2),treatment=letters[1:2],bp = rnorm(10)) d %>% # Assume piped manipulations here # Make wide # Assume additional piped manipulations here # Make wide (old style) with(d,left_join(d[treatment=="a",], d[treatment=="b",],by="subject" ))
r dplyr magrittr reshape2
Dieter Menne Dec 11 '14 at 9:03 2014-12-11 09:03
source share