Home > database >  Transform a "Year-ISO Week" character object to a Date object
Transform a "Year-ISO Week" character object to a Date object

Time:12-14

I've been having some struggles with dates. Namely, being able recognize a variable (as a Datevariable) that has dates registered by the following manner: Year-ISO week. So the following code:

class("2021-20")

Idealy should return: Date .

The following code recognizes it as a date, but it returns a date that I don't understand where it comes from. And even if I try with other dates (different values of the ISO week), I always get the same response:

as.Date("2021-20", format = "%Y-%W")
[1] "2021-12-13"

I've tried transforming "normal dates" to the format year-iso week, but it leads to no where, I can never get it to be recognized as a Dateobject, and I need to perform ggplot2graphs.

This question was linked to this enter image description here

  • Related