Displaying 2 results from an estimated 2 matches for "rep_week".
2018 May 09
0
Seasonal weekly average
...sample(1:12,500,TRUE),
sample(2013:2017,500,TRUE),sep="/")
# if this isn't your format, change it
date_format<-"%d/%m/%Y"
# create a data frame with a column of dates
rep_df<-data.frame(rep_dates=as.Date(rep_dates,format=date_format))
# add the week of the year
rep_df$rep_week<-format(rep_df$rep_dates,"%V")
# add the year
rep_df$rep_year<-format(rep_df$rep_dates,"%Y")
# get a table of the weekly counts by year
rep_tab<-table(rep_df$rep_week,rep_df$rep_year)
# get the row means (5 year averages)
rep5<-apply(rep_tab,1,mean)
# plot the 5 year...
2018 May 09
3
Seasonal weekly average
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; another line will then plot the current year, enabling a comparison of current weekly counts