Extract month and year from a zoo::yearmon object

Use the format() method for objects of class “yearmon”. Here is your example date (properly created!) date1 <- as.yearmon(“Mar 2012”, “%b %Y”) Then we can extract the date parts as required: > format(date1, “%b”) ## Month, char, abbreviated [1] “Mar” > format(date1, “%Y”) ## Year with century [1] “2012” > format(date1, “%m”) ## numeric month … Read more