EpiCurve: Plot an Epidemic Curve

Description Usage Arguments Details Author(s) References Examples

View source: R/EpiCurve..R

Description

This function plot an epidemic curve with ggplot2

Usage

1
2
3
EpiCurve(x, date = NULL,freq = NULL, cutvar = NULL,
   period = NULL, to.period = NULL, split = 1, cutorder = NULL, colors = NULL,
   title = NULL, xlabel = NULL, ylabel=NULL, note=NULL, square = TRUE)

Arguments

x

data.frame with at least one column with Date type

date

character, name of Date column

freq

character, name of a column with a value to display

cutvar

character, name of a column with factors

period

character, c("hour", "day","week", "month")

to.period

character, Convert date period to another period only for aggregated data. If period is "day", to.period can be "week" or "month". If period is "week", to.period can be "month".

split

integer, c(1,2,3,4,6,8,12) Value for hourly split

cutorder

character vector of factors

colors

character vector of colors

title

character, title of the plot

xlabel

character, label for x axis

ylabel

character, label for y axis

note

character, add a note under the graph

square

boolean, If TRUE (default) squares are used to plot the curve, else if the number of cases is too hight please use square = FALSE

Details

When period is "week" the date MUST be in ISOweek format YYYY-WNN and library ISOweek is needed. When period is "month" the date MUST be formated YYYY-MM.

When period is "hour" the date MUST be in timeDate format (YYYY-mm-dd HH:MM:SS) or (YYYY-mm-dd HH:MM)

Author(s)

<jean.pierre.decorps@gmail.com>

References

<https://rlab-epiconcept.blogspot.fr/2016/09/courbes-epidemiques-avec-ggplot2.html>

<https://fr.wikipedia.org/wiki/Courbe_épidémique>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# library(EpiCurve)
date <- seq(as.timeDate("2017-05-10 21:35:22"), as.timeDate("2017-05-12 06:15:12"), by="12 min")
val <- rep(1, length(date))
tri <- rep(c("Alive", "Died","Unknown"), length.out=length(date))
DF <- data.frame(date, val, tri, stringsAsFactors=TRUE)
names(DF) <- c("date","value", "tri")


EpiCurve(DF,
         date = "date",
         freq = "value",
         period = "hour",
         split = 4,
         cutvar = "tri",
         ylabel="Number of cases",
         xlabel= "From 2017-05-10 21:35:22 To 2017-05-12 06:15:12",
         title = "Epidemic Curve")

IamKDO/EpiCurve documentation built on Aug. 6, 2021, 2:13 p.m.