Reputation: 5049
How do I convert a string "Apr-16" to Month
April of 2016 ?
I tired as.Date(x, format ..)
, that isn't helping .
What options do I have here ?
Upvotes: 2
Views: 3619
Reputation: 886938
Another option is regex
sub("-", "il of 20", x)
#[1] "April of 2016"
Or using yearmon
from zoo
library(zoo)
format(as.Date(as.yearmon(x, "%b-%y")), "%B of %Y")
#[1] "April of 2016"
x <- "Apr-16"
Upvotes: 1
Reputation: 2070
x <- "Apr-16"
x <- as.Date(paste0("1-",x),format="%d-%b-%y")
format(x,"%B of %Y")
[1] "April of 2016"
Upvotes: 4