I have a list as follows:
id | value
----------
4 600
4 899
7 19
13 4930
13 300
: :
There are multiple ID
You could also use tapply
if you want to stick with base functions:
tapply(dat$value,dat$id,c)
$`4`
[1] 600 899
$`7`
[1] 19
$`13`
[1] 4930 300
Edit:
For your edited problem, I would go with split
and lapply
:
x <- lapply(split(dat[2:3],dat$id),c,use.names=F)
dput(x)
structure(list(`4` = list(c(600, 899), c("a", "b")), `7` = list(
19, "d"), `13` = list(c(4930, 300), c("e", "a"))), .Names = c("4", "7", "13"))