In my code below, I want to first remove the
Variable for which i do not have any value (Ie., F should be removed where all the values are 'NA'). then i am trying to find accumulated values of each
Variable. I tried with the following code but i am not getting anything out of it.
library(tidyverse) set.seed(50) DF <- data.frame(Days = 1:5, A = runif(5,0,3), S = runif(5,1,6), F = matrix(NA, 5,1), C = runif(5,2,4)) DF_1 <- gather(DF, -Days, key = "Variable", value = "Value") DF_2 <- DF_1 %>% filter(Variable == "NA") %>% mutate(cumulative_Sum = cumsum(Value))
Variable A I should get something like below- similar for others
> A <- cumsum(DF$A) > A  2.126181 3.439161 4.039176 6.340374 7.879859