I have two lists as below:
l1 <- list(a=1, b=2, c=3)
l2 <- list(a=4, b=5, c=6)
I want to calculate the mean value of the two lists for each row and assign the result to a new list. Like below:
l3 <- mean(l1, l2)
How can I achieve this in R?
Using:
colMeans(do.call(rbind.data.frame, list(l1,l2)))
gives:
a b c
2.5 3.5 4.5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With