I am trying to replace counts in a table with the cumulative totals row-wise. In the example below the first row currently reads 8, 12, 1, 6, 6, and I want it to read 8, 20, 21, 27, 33. I know I could do this through a loop, but there must be a simpler way. I would love to do this outside the tidyverse if possible.
o <- structure(c(8, 1, 9, 2, 3, 2, 25, 12, 15, 21, 19, 17, 6, 90,
1, 19, 23, 22, 14, 5, 84, 6, 20, 31, 28, 28, 12, 125, 6, 23,
37, 28, 25, 15, 134), .Dim = c(7L, 5L), .Dimnames = structure(list(
c("1", "2", "3", "4", "5", "6", "Sum"), c("1", "2", "3",
"4", "5")), .Names = c("", "")), class = "table")
print( o )