Dear list,

here is an example of my dataset:

date <- c("20-08-2005", "27-08-2005", "19-08-2005", "29-08-2005", "01-08-2005", "01-08-2005", "25-08-2005", "15-08-2005", "11-08-2005", "12-08-2005", "18-08-2005", "02-08-2005", "04-08-2005", "15-08-2005", "17-08-2005", "24-08-2005", "15-08-2005", "30-08-2005", "30-08-2005", "02-08-2005", "05-08-2005", "04-08-2005", "22-08-2005", "11-08-2005", "25-08-2005", "29-08-2005", "07-08-2005", "04-08-2005", "08-08-2005", "08-08-2005")
hcrime <- factor(c("Aggravated Assault", "Burglary", "Robbery"))
data <- cbind(date, hcrime)

I have following questions:
a) how can I find out the weeks of every date
b) aggregate the dates falling in the same week
c) sum up the different crimes per week

for better understanding here is an example for a) and b):
date                    week
27-08-2005            99
27-08-2005            99
29-08-2005            99

and here one for c):

week    crimes_Robbery    crimes_Robbery
98                2                            1
99                3                            0

thank you very much for your help!
best regards
Marco

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to