Here is my current data, using R, I sorted the dates into Year/Month/Day; however, now I wish to sort them into weeks.
library(tidyr)
library(astsa)
mydata <- read.csv("/Users/Shannon/Documents/PoliceKillingsUS.csv", header = TRUE, sep = ",", dec = ".")
mydata$ddate <- format(as.Date(mydata$date, format = "%d/%m/%y"), "%Y/%m/%d")
sort(mydata$ddate)
Ideally, the output that I would want is as follows. Though if we cannot start with week 0, that is fine.
ddate week
1 2015-1-2 0
2 2015-1-3 0
3 2015-1-10 1
4 2015-1-18 2
I did read this group-by-week thread in stackoverflow, but unfortunately, I kept getting errors. Group dates by week in R