0

My dataset includes a date indicator in the ISO Week format (202148, 202149 etc.). Unfortunately, ggplot does not recognize this indicator as a date class, which leads to a break in the plot. [Plot with time break][1]

How can I convert it to the date class? I already tried the following:

data$date <- as.Date(data$date)```


  [1]: https://i.stack.imgur.com/xlyQx.png
Nick Glättli
  • 421
  • 1
  • 7

1 Answers1

0
some_dates <- as.POSIXct(c("2021-12-24", "2021-12-31", "2021-01-01", "2021-01-08"))


(year_week <- format(some_dates, "%Y %U"))


(year_week_day <- sprintf("%s 1", year_week))


(as.POSIXct(year_week_day, format = "%Y %U %u"))
Rfanatic
  • 2,224
  • 1
  • 5
  • 21