I have a dataset like the following:
| ID | Winter | Spring | Summer | Fall |
|---|---|---|---|---|
| 1 | high | NA | high | low |
| 2 | low | high | NA | low |
| 3 | low | NA | NA | low |
| 4 | low | high | NA | low |
I would like to add a calculated column so that if any of the winter, spring, summer, and fall columns contains "high," then "1" is added to that row as shown below. Otherwise it will contain 0.
| ID | Winter | Spring | Summer | Fall | calculated_column |
|---|---|---|---|---|---|
| 1 | high | NA | high | low | 1 |
| 2 | low | high | NA | low | 1 |
| 3 | low | NA | NA | low | 0 |
| 4 | low | high | NA | low | 1 |
So far I have something like this, I know it's incorrect. I'm not sure how to specify multiple columns rather than just one:
df$calculated_column <- ifelse(c(2:5)=="High",1,0)