0

I've the following vector

x <- c("June 25, 2021","July 2, 2021","July 9, 2021", "July 16, 2021", "July 23, 2021", "July 30, 2021", "August 20, 2021",
   "September 17, 2021", "October 15, 2021", "November 19, 2021", "December 17, 2021", "January 21, 2022", "June 17, 2022",
   "September 16, 2022", "January 20, 2023", "March 17, 2023", "June 16, 2023")

Then, I need to convert it from character into dates. I tried

expiries <- as.Date(x, format = "%b %d, %Y")

but the result is

class(expiries)
[1] "Date"

expiries
[1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA

Do you have any suggestion to get dates and not NAs?

My final aim is to calculate the difference between the values in expiries and another date set as the starting point.

Slaum
  • 3
  • 3
  • 3
    Works fine for me. Your locale is probably other than English, hence you are getting `NA`'s. Change the locale to English from here https://stackoverflow.com/questions/16347731/how-to-change-the-locale-of-r and try again – Ronak Shah Jun 24 '21 at 10:26
  • Thank you, I've solved by adding `Sys.setlocale("LC_ALL","English")`. – Slaum Jun 24 '21 at 13:18

0 Answers0