I have a dataframe of comments where one column df$date corresponds to the dates when the comment was made, expressed as shown below:
[1] "2019-06-01" "2019-07-01" "2019-10-01" "2019-10-01" "2019-09-01" "2019-04-01" "2019-04-01" "2019-04-01" "2019-04-01"
[10] "2019-04-01" "2018-08-01" "2018-08-01" "2018-08-01" "2018-07-01" "2018-08-01" "2018-07-01" "2018-07-01" "2018-06-01"
I want to add a new column with the seasons. Basically, I want to say that if the date was made between December and February, then the corresponding season would be winter. I have tried the following, but it gives me: "Error: Not compatible with requested type: [type=character; target=double]."
df$season = ifelse(between(df$date,"2018-11-30", "2019-03-01"), "Invierno"
ifelse(between(df$date,"2019-02-28", "2019-06-01"),"Spring", ifelse(between(df$date,"2019-06-30", "2019-07-01"),"Summer",
"Fall")))
Does this mean I have to reformat the date to character or is there any way I could create the seasons column using the date format?
Thanks in advance!