AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
2018 week number calendar9/8/2023 I provided a link to my simple geneorama package, but please don't rely on it too much because it's likely to change and not very documented.Version for the United Kingdom with UK bank holidays. The best way to do this would be to add an offset to the offset. Of course, you can easily change the offset to make Monday first or whatever. Offset <- data.table(weekday = c('Sunday', 'Monday', 'Tuesday', 'Wednesday', ![]() I day weekday day_rounded weekday_rounded weeknumber # This seems to make internal sense with the "week" calculation # Now let's add the weekdays for the "rounded" dateĭt I don't understand the internal mechanics, but you can see what I mean with this example: library(data.table) I think the problem is that the week calculation somehow uses the first day of the year. No = ifelse(test = month(date) = 1 & as.integer(substr(yearweek, 5, 6)) > 51, Mutate(yearweek2 = ifelse(test = day(date) > 7 & substr(yearweek, 5, 6) = '01', Mutate(yearweek = as.integer(strftime(date, format = "%Y%V"))) %>% In column "yearweek" the years are sometimes wrong, in "yearweek2" they are corrected (rows 2 and 5). This codes provides some examples and a solution. For instance, (yyyy-mm-dd) is week 53 of year 2015, not 2016. If you want to get the week number with the year, Grant Shannon's solution using strftime works, but you need to make some corrections for the dates around january 1st.
0 Comments
Read More
Leave a Reply. |