Let’s say you’ve got data like this.
Now how can we convert this to Date so that we can do all kinds of Date related operation?
Here’s how.
First, you want to replace ‘Week’ text with ‘-’.
str_replace(week, " Week ", "-")
Then you can do something like this by using R’s function ‘as.Date’.
as.Date(str_c(week2, "-1"), format="%Y-%U-%u")
Note that you need to use ‘%u’, which is a day of week, instead of ‘%d’ (day of month).
By putting them all together it would look something like this.