i have a panel data. the variable of interest have two values,1 and 0. i would like to replace 0 with 1 by group if 1 is in front of 0 . The data is as follow,
id <- c(1,1,2,2,2,3,3,3,4,4);
burden <- c(0,0,0,1,0,1,0,0,0,1)
i expect to get the following results,
burden <- c(0,0,0,1,1,1,1,1,0,1)
Thanks for any help in advance!