Reputation: 75
I'm using the function as.yearqtr() from the zoo package to convert a date like this:
2012-01-01
...and I would like to have it like this:
2012Q1
The problem with as.yearqtr is that it create a blank space between the year and the 'Q':
2012 Q1
How can I remove this blank?
Thanks!
Upvotes: 2
Views: 480
Reputation: 887048
We can change with format
. It would no longer have the class
yearqtr
, but would be just character
library(zoo)
format(as.yearqtr('2012-01-01'), '%YQ%q')
#[1] "2012Q1"
Or with regex
sub(" ", "", as.yearqtr('2012-01-01'))
Upvotes: 1