0

I started working in R and need to change a date. On my search I only found how to change the format or setting the day/month/year to a specific number. I have for example:

my_date = as.Date("2020-03-01")

in my algorithm I need to change this by one day. For this special case I am looking for

2020-02-29

Thanks for your answers.

Best Felix

Pet
  • 251
  • 1
  • 3
  • 14

1 Answers1

0

I would propose to use lubridate library.

Then:

library(lubridate)
date <- ymd("2020-03-01")
date - days(1)

gives you "2020-02-29".

Piotr K
  • 943
  • 9
  • 20