I was wondering how if I could make 7 other data.frames out of dat1 using lapply such that at each round from left to right each pair of 1s in C1 and C2 become 0 except the last two elements of C1 and C2? (see desired output below)
dat1 <- data.frame(C1 = c(1, 1, 1, 1, 1, 1, 1, 1, 0, 0),
C2 = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1))
dat2 <- data.frame(C1 = c(0, 1, 1, 1, 1, 1, 1, 1, 0, 0),
C2 = c(0, 1, 1, 1, 1, 1, 1, 1, 1, 1))
dat3 <- data.frame(C1 = c(0, 0, 1, 1, 1, 1, 1, 1, 0, 0),
C2 = c(0, 0, 1, 1, 1, 1, 1, 1, 1, 1))
dat4 <- data.frame(C1 = c(0, 0, 0, 1, 1, 1, 1, 1, 0, 0),
C2 = c(0, 0, 0, 1, 1, 1, 1, 1, 1, 1))
.
.
.
dat8 <- data.frame(C1 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0), # the last desired data.frame
C2 = c(0, 0, 0, 0, 0, 0, 0, 0, 1, 1))