I have a data frame with Date in the "%d-%m-%Y" format and have the week number. The dates are weekdays and I want the the Saturday for that week in another column.
I had initially check whether the date is a weekday or weekend using function in the Chron package but that was a Boolean validation. I had formatted the date variable to Date format and extracted the week number for each date.
df = data.frame(date=c("2014-08-20", "2014-08-25", "2014-10-08"))
df$date=as.Date(df$date,format="%Y-%m-%d")
df$week=week(ymd(df$date))
The expected result should be:
date week EOW
2014-08-20 34 2014-08-23
2014-08-25 34 2014-08-30
2014-10-08 41 2014-10-11