I would like to create a new column in my data.frame: mad$season
that is filled with conditional categories:
mad$season <- ifelse(mad$dayofyear <81, "winter", "")
mad$season <- ifelse((mad$dayofyear>=80) & (mad$dayofyear<=108), "spring", "")
mad$season <- ifelse(mad$dayofyear >108, "summer", "")
Similar to this example: R: Add multiple new columns based on multiple conditions
However, each line of code replaces the first - and NULL doesn't appear to work.
Any suggestions?
This question is different from Replacing numbers within a range with a factor because I wanted to add a new column, not replace the number with a factor.