On Sat, 13 Apr 2019, Christofer Bogaso wrote:

Hi,

I am wondering if there is any way to get the full name from as.yearmon()
function. Please consider below example:

library(quantmod)
as.yearmon(Sys.Date())

This gives: [1] "Apr 2019".

How can I extract the full name ie. 'April 2019'

Internally, printing/formatting of yearmon objects uses the format method for Date objects, see ?format.Date. The default is "%b %Y" where %b is the abbreviated month name in the current locale. %B gives you the full month name, both for Date directly and for yearmon:

R> format(Sys.Date(), "%B %Y")
[1] "April 2019"
R> format(as.yearmon(Sys.Date()), "%B %Y")
[1] "April 2019"


Appreciate your pointer. Thanks,

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to