Using R, if I have a 2 column data frame:
meta <- c(1,2,2,3,4,4,4,5)
value <- c("a","b","c","d","e","f","g","h")
df <- data.frame(meta,value)
df
meta value
1 1 a
2 2 b
3 2 c
4 3 d
5 4 e
6 4 f
7 4 g
8 5 h
How would I go about combining “value” with a delimiter (like ||) by repeated “meta” such that the resulting data frame would look like:
meta value
1 1 a
2 2 b||c
3 3 d
4 4 e||f||g
5 5 h
Thanks!
Using the
plyrpackage the following worksor
if you want to preserve names