I have data frame which has the date column in format 08/21/2000(m/d/Y)
.
Now I want to add new column which display the date in Quarter format that is 2000-Q3
.
I install zoo package and used following command. but it is giving NA
value.
library(zoo)
mydf$var9=as.yearqtr("mydf$Order.Date","%m/%d/%Y").
The zoo library has created a set of functions to handle year-quarter vectors:
library(zoo)
mydf$var9=as.yearqtr(as.Date( mydf$Order.Date, "%m/%d/%Y" ).
来源:https://stackoverflow.com/questions/18349910/convert-date-field-to-quarter-in-r