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?
Aucun commentaire:
Enregistrer un commentaire