[R] Seasonal weekly average

Eric Berger er|cjberger @end|ng |rom gm@||@com
Wed May 9 10:07:51 CEST 2018

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 the second line.
Or you can go with the ggplot2 package for the charts but that might
require a bit more time to get up to speed.

Good luck,

On Wed, May 9, 2018 at 9:37 AM, Shakeel Suleman <Shakeel.Suleman using phe.gov.uk>

> 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 against a five  year average for the same week. I would like
> some advice on how this can be done in 'R' . My data is disaggregated data
> - with dates in the format in 01/01/2018.
> Thanks
> Shakeel Suleman
> **************************************************************************
> The information contained in the EMail and any attachments is confidential
> and intended solely and for the attention and use of the named
> addressee(s). It may not be disclosed to any other person without the
> express authority of Public Health England, or the intended recipient, or
> both. If you are not the intended recipient, you must not disclose, copy,
> distribute or retain this message or any part of it. This footnote also
> confirms that this EMail has been swept for computer viruses by
> Symantec.Cloud, but please re-sweep any attachments before opening or
> saving. http://www.gov.uk/PHE
> **************************************************************************
>         [[alternative HTML version deleted]]
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

	[[alternative HTML version deleted]]

More information about the R-help mailing list