Been searching around but with no luck so far.
Here is the data frame.
> test = data.frame(x = c(1,1,2,2,3,3), y = c('a','b','c','d','e','f'))
> test
x y
1 1 a
2 1 b
3 2 c
4 2 d
5 3 e
6 3 f
Was looking for a way to aggregate such that y with identical x value with be formed into a list or vector.
Something like
x y
1 1 a,b
2 2 c,d
3 3 e,f
Tried 'c' but the result is not what was expected
> aggregate(y~x, data = test, FUN = 'c')
x y.1 y.2
1 1 1 2
2 2 3 4
3 3 5 6
'list' seems to work, but it converts character to factor, though.
> ss = aggregate(y~x, data = test, FUN = 'list')
> class(ss$y[1][[1]])
[1] "factor"
> ss$y[1]
$`1`
[1] a b
Levels: a b c d e f
Any comments is appreciated, thank you.