How to get week starting date from a date in R
You can use below
as.Date(format(as.Date("04/20/2017", "%m/%d/%Y"),"%Y-%W-1"),"%Y-%W-%u")
[1] "2017-04-17"
Use the floor_date
function from the lubridate
package.
library("lubridate")
floor_date(as.Date("04/20/2017", "%m/%d/%Y"), unit="week")