Hello, I have a list "ll - see below" on which I would like to apply a function accessing every pair of elements in the list. For instance, I want to apply the "sum" function on "6635 + 6636" and return the sum, the on "6635 + 6637", ... Any hint to do that using apply / mapply / rapply ? Thanks,> ll[[1]] [1] "6635" "6636" [[2]] [1] "6635" "6637" [[3]] [1] "6636" "6637" -- View this message in context: http://r.789695.n4.nabble.com/Apply-function-over-elemetns-of-a-list-tp2952538p2952538.html Sent from the R help mailing list archive at Nabble.com.
On 02.10.2010 18:00, PQuery wrote:> > Hello, > > I have a list "ll - see below" on which I would like to apply a function > accessing every pair of elements in the list. For instance, I want to apply > the "sum" function on "6635 + 6636" and return the sum, the on "6635 + > 6637", ... > > Any hint to do that using apply / mapply / rapply ? > > Thanks, > >> ll > [[1]] > [1] "6635" "6636" > > [[2]] > [1] "6635" "6637" > > [[3]] > [1] "6636" "6637"sapply(ll, sum) Uwe Ligges