Re: [R] Seasonal weekly average

2018-05-09 Thread MacQueen, Don
I would just add, see ?strptime for information about those date format specifications ( "%V" for example), and an introduction to R's handling of date and date-time values. And a few quick examples, to see that %V works as advertised: > format( Sys.Date() , '%V') [1] "19" > format(

Re: [R] Seasonal weekly average

2018-05-09 Thread Jim Lemon
Hi Shakeel, Assuming that you are starting with a bunch of dates: # make a vector of character strings that can be converted to dates rep_dates<-paste(sample(1:30,500,TRUE),sample(1:12,500,TRUE), sample(2013:2017,500,TRUE),sep="/") # if this isn't your format, change it date_format<-"%d/%m/%Y" #

Re: [R] Seasonal weekly average

2018-05-09 Thread Eric Berger
Hi Shakeel, One approach would be to look at the dplyr package and its functions group_by() and summarise(). These should be useful in preparing the data. (Alternatively if you know SQL you might look at dbplyr.) On the plotting side you can use plot(...) for the first line and then lines(...) for

[R] Seasonal weekly average

2018-05-09 Thread Shakeel Suleman
Hi, I am fairly new to 'R' and would like advice on the following. I want to calculate a weekly average number of reports (e.g. of flu, norovirus) based on the same weeks for the last five years. I will then use this to plot a chart with 52 points for the average based on the last five years;