I am trying to convert a Y into a 1 for a number of columns that could change (e.g. it could go up to x20).
An example of the data is below as well as an expected output.
Data <- tibble(Date = seq.Date(as.Date('2019-01-01'),as.Date('2019-01-08'), by = "day"),
x1 = c("Y","","","Y","Y","","Y","Y"),
x2 = c("","Y","Y","Y","Y","","Y","Y"))
Data_output <- tibble(Date = seq.Date(as.Date('2019-01-01'),as.Date('2019-01-08'), by = "day"),
x1 = c(1,0,0,1,1,0,1,1),
x2 = c(0,1,1,1,1,0,1,1))