我该怎么走
df<-data.frame(id=c("A", "B", "B"), res=c("one", "two", "three"))
df
到
df.output<-data.frame(id=c("A", "B"), res1=c("one", "two"), res2=c(NA, "three"))
df.output
dplyr
美元?
I do not know a priori the number of duplicates in id
(in this example B
has 2 occurrences), so the number of resX
variables in the output data frame has 到 be generated on the fly.