In R, how do I output a lubridate compatible date in yyyymmdd format? The equivalent of .ToString("yyyyMMdd") in .NET?

StackOverflow https://stackoverflow.com/questions/14716443

  •  06-03-2022
  •  | 
  •  

Вопрос

In R, I can parse a date into Lubridate format using:

d <- ymd("2013-02-15")

How do I output this in yyyyMMdd format, e.g.:

20130215

The equivalent .NET command would be:

.ToString("yyyyMMdd")

I know the answer to this will be simple, but I've spent the last hour attempting to find any reference to outputting dates with Lubridate with no success so far.

Это было полезно?

Решение

format(d, "%Y%m%d")

yields

> format(d, "%Y%m%d")
[1] "20130215"
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top