It is hard to explain, but I have a data.frame (2.915 rows) with ID column and years columns:
In this data.frame I want to verify if any ID has the sequence 1,0 (one or more years with zero),1* in the columns.
Like this:
I mean, a flag column would be useful.
data$flag[data$ID %in% seq] <- c("Y")
How can I do it?
My data:
structure(list(ID = c("5453", "6675", "7745",
"68621", "33356", "7855"), `2000` = c(0,
0, 1, 0, 1, 0), `2001` = c(0, 0, 1, 0, 1, 0), `2002` = c(0, 0,
1, 0, 1, 0), `2003` = c(0, 0, 1, 0, 1, 0), `2004` = c(1, 0, 1,
0, 1, 1), `2005` = c(0, 1, 1, 0, 1, 1), `2006` = c(1, 1, 1, 0,
1, 1), `2007` = c(1, 1, 1, 0, 1, 1), `2008` = c(1, 1, 1, 1, 1,
1), `2009` = c(1, 1, 1, 1, 1, 1), `2010` = c(1, 1, 1, 1, 0, 1
), `2011` = c(1, 1, 1, 0, 0, 1), `2012` = c(1, 1, 1, 0, 0, 1),
`2013` = c(1, 1, 1, 0, 0, 1), `2014` = c(1, 1, 1, 0, 0, 1
), `2015` = c(1, 1, 1, 0, 0, 1), `2016` = c(1, 1, 1, 0, 0,
1), `2017` = c(0, 0, 0, 0, 0, 0), `2018` = c(0, 0, 0, 0,
0, 0)), row.names = c(NA, 6L), class = "data.frame")