Description Usage Arguments Details Author(s) References Examples
This function plot an epidemic curve with ggplot2
1 2 3 |
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 |
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)
<jean.pierre.decorps@gmail.com>
<https://rlab-epiconcept.blogspot.fr/2016/09/courbes-epidemiques-avec-ggplot2.html>
<https://fr.wikipedia.org/wiki/Courbe_épidémique>
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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.