Date |
---|
1960Q1 |
1960Q2 |
1960Q3 |
1960Q4 |
1961Q1 |
1961Q2 |
I have the following data.frame. I am trying to put this first column into a tsibble. Now I have a problem. How can I switch to a date so that it can be read as a quarter.
I tried zoo
using
DATA.QTR <- DATA.QTR %>% mutate(QUARTER = as.Date(as.yearqtr(Date, "%Y %Q")))
but it's not reading it.
You almost got it! The format needs to be sligthly adapted.
%YQ%q
:%Y
stands for the year,Q
stands for the Q in your inital format and%q
stands for the quarter.Code
Output
Data