The functions in the plyr package should help here.
In the following example, I assume that your data is in the form of data.frame - even if it is really a list, as you say, it should be direct to convert to data.frame:
dat <- data.frame( id = c(4, 4, 7, 13, 13), value = c(600, 899, 19, 4930, 300) ) library(plyr) dlply(dat, .(id), function(x)x$value)
The result is the list you specified:
$`4` [1] 600 899 $`7` [1] 19 $`13` [1] 4930 300 attr(,"split_type") [1] "data.frame" attr(,"split_labels") id 1 4 2 7 3 13
Andrie
source share