Hi there,
I am trying to calculate a cumsum in a column that has NA values. I tried this code:
library(dplyr)
library(tidyr)
df3 %>%
mutate(
cum_completed = cumsum((replace_na(x, 0))completed),
cum_incomplete = cumsum((replace_na(x, 0))incomplete)) %>%
print()
but get the following error message:
library(tidyr)
df3 %>%
- mutate(
cum_completed = cumsum((replace_na(x, 0))completed),
Error: unexpected symbol in:
" mutate(
cum_completed = cumsum((replace_na(x, 0))completed"
Not sure what is wrong. Any help or advice is much appreciated.
Kind Regards
Aaron