I have a question regarding negative cumulative sum in R through the rows, how can I get the desired output:
# TEST
data <- data.frame(
`Delivery Year` = c('1976','1977','1978','1979'),
`Freq` = c(120,100,80,60),
`Year.1976` = c(10,3,8,0),
`Year.1977` = c(5,0,5,0),
`Year.1978` = c(10,10,0,0),
`Year.1979` = c(13,0,0,14)
)
data
# DESIRED
data <- data.frame(
`Delivery Year` = c('1976','1977','1978','1979'),
`Freq` = c(120,100,80,60),
`Year.1` = c(110,97,72,60),
`Year.2` = c(105,97,67,60),
`Year.3` = c(95,87,67,60),
`Year.4` = c(82,87,67,46)
)
data
