I have a sample dataset which is as follows:
df <- structure(list(Category1 = c("Alpha: 0", "Alpha: 0", "Alpha: 0",
"Alpha: 3", "Alpha: 0"),
Category2 = c("Beta: 1", "Beta: 0", "Beta:0",
"Beta: 1", "Beta: 1"),
Category3 = c("Charlie: 2", "Charlie: 0",
"Charlie: 0", "Charlie: 2", "Charlie: 2"),
Output = c(NA, NA, NA, NA, NA)), class = "data.frame", row.names = c(NA, -5L ))
I am trying to add binary values of 1 or 0 in the Output column based on the values in Category1, Category2, Category3 columns. If the value in each of these columns is as follows: "Alpha: 0", "Beta: 0" and "Charlie: 0" then I would like to have "1" added in the same row under the Output column. For any other combinations, I would like to have "0" added in the Output column. Any suggestions on how this can be accomplished in a simplistic manner?
Thanks!