How to get sum of the list using mapply in r
mapply, r
Solution
I got it. I used `Reduce("+", o)` instead of `mapply`.
Problem
I have a list of 100 elements, and each element contains 431 elements. i want to use mapply to sum the values from each list. For example, say I have a list of 5 elements, but each element has another 5 elements. ``` > o [[1]] [1] 1 2 3 4 5 [[2]] [1] 1 2 3 4 5 [[3]] [1] 1 2 3 4 5 [[4]] [1] 1 2 3 4 5 [[5]] [1] 1 2 3 4 5 > mapply(sum, o[[1]], o[[2]], o[[3]], o[[4]], o[[5]]) [1] 5 10 15 20 25 ``` But how can I do this for say 100 elements. It's not feasible to type in 100 elements as args. Can somebody please help? Thank you