Title: | Plot an Epidemic Curve |
---|---|
Description: | Creates simple or stacked epidemic curves for hourly, daily, weekly or monthly outcome data. |
Authors: | Jean Pierre Decorps [aut, cre] |
Maintainer: | Jean Pierre Decorps <[email protected]> |
License: | LGPL-3 |
Version: | 2.4-2 |
Built: | 2024-11-09 04:38:27 UTC |
Source: | https://github.com/IamKDO/EpiCurve |
This function plot an epidemic curve with ggplot2
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)
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)
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)
<https://rlab-epiconcept.blogspot.fr/2016/09/courbes-epidemiques-avec-ggplot2.html>
<https://fr.wikipedia.org/wiki/Courbe_épidémique>
# 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")
# 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")