#' A figure for predicted daily hospitalization.
#' @description To show a figure for predicted daily hospitalization.
#' @import stats ggplot2
#' @importFrom reshape2 melt
#' @param showdays Input. Number of days to project.
#' @param dailyhosp Input. Object from function \emph{Prehos.daily}.
#' @examples ## To predicte 100 days from today (dayFT=100).
#' @examples casevolumne <- fitSIR(susceptible=4119405, Infected=3733, inihos=14,
#' @examples hosrate=2.5, hms=15, inidbt=4, mrt=14, sdis=30, dayFT=100)
#' @examples dailyhosp <- Prehos.daily(casevolumne, hosrate=2.5, icurate=0.75, venrate=0.5, hms=15)
#' @examples hospfig.daily(showdays=60, dailyhosp) ## show the first 60 days
#'
#' @export
hospfig.daily <- function(showdays=60, dailyhosp) {
if (showdays > nrow(dailyhosp) - 1) {
showdays <- nrow(dailyhosp) - 1
}
dd <- reshape2::melt(dailyhosp[1:(showdays+1),], id=c("days.from.today"))
levels(dd$variable) <- c("Hospitalized", "ICU", "Ventilated")
pp <- ggplot() +
geom_line(data=dd, aes(x=days.from.today, y=value, colour=variable), size=1) +
geom_point(data=dd, aes(x=days.from.today, y=value, colour=variable), size=2) +
xlab("Date") +
ylab("Daily Admissions to Hospital") +
theme(axis.text=element_text(size=16), ## change size of text
axis.title=element_text(size=18, face="bold")) + # change size of label name
theme(legend.text=element_text(size=16)) + # change text size in legend
theme(legend.title=element_text(size=16)) + # change title size of legend
guides(col=guide_legend("Level")) +
scale_colour_manual(values=c("blue","orange","red"))
currentCDTDate <- function() as.Date(format(Sys.time(), tz="America/Chicago"))
break1 <- round(seq(0,showdays,length.out=7))
labels1 <- format(break1 + currentCDTDate(), "%b/%d")
pp + scale_x_continuous(breaks=break1, labels=labels1) +
theme(axis.text.x = element_text(size=14, angle=30, vjust = 0.8))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.