epicurve: Create epicurve

Description Usage Arguments Value Author(s) Examples

View source: R/epicurve.R

Description

Create epicurve

Usage

1
2
3
4
5
6
epicurve(x, date.col, time.period = NULL, start.at = NULL,
  stop.at = NULL, fill.by = NULL, split.by = NULL, shade.by = NULL,
  xlab = NULL, ylab = "Number of cases", fill.by.legend.title = NULL,
  shade.by.legend.title = NULL, angle = 90, col.pal = "phe",
  label.breaks = 0, epi.squares = TRUE, blank.background = TRUE,
  na.rm = TRUE)

Arguments

x

a data.frame

date.col

a character specifying the column containing dates

time.period

a character of the desired time period for the epicurve, this can either be day, year, month, year.month, iso.year, iso.week, iso.year.week, use.date.col.as.is NOTE: if time.period = use.date.col.as.is the date.col will be treated as a factor and will be used as the x-axis

start.at

a character in the format "yyyy-mm-dd" to specify the start date for the epicurve

stop.at

a character in the format "yyyy-mm-dd" to specify the stop date for the epicurve

fill.by

a character specifying the column to stratify by using colour

split.by

a character specifying the column to facet by

shade.by

a character specifying the column to stratify by using shading

xlab

a character specifying the x-axis label for the epicurve

ylab

a character specifying the y-axis label for the epicurve

fill.by.legend.title

a character specifying the fill legend title

shade.by.legend.title

a character specifying the shade legend title

angle

a numeric to specify the x-axis label angel for the epicurve

col.pal

a numeric specifying the colour palette (range 1-8 inclusive) OR a character stating 'phe' to use the phe colour palette

label.breaks

a numeric specifying the interval for x-axis label breaks

epi.squares

a logical specifying if episquares should be used on the epicurve

blank.background

a logical specifying if the figure background should be blank

na.rm

a logical specifying if missing dates should be removed from the epicurve

Value

an epicurve

Author(s)

Daniel Gardiner (daniel.gardiner@phe.gov.uk)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# set dummy data

set.seed(2)

data = data.frame(dates = sample(seq(as.Date('2014-01-01'), as.Date('2016-04-01'), by="day"), 200, replace = TRUE),
                  sex = c("Male", "Female"),
                  conf = sample(c("Confirmed", "Probable", "possible"), 200, replace = TRUE),
                  status = sample(c("Student", "Staff"), 200, replace = TRUE))


# use function

epicurve(data,
         date.col = "dates")

epicurve(data,
         date.col = "dates",
         start.at = "2015-01-01",
         stop.at = "2016-05-15")

epicurve(data,
         date.col = "dates",
         start.at = "2015-01-01",
         stop.at = "2016-05-15",
         time.period = "iso.year.week",
         label.breaks = 2)

epicurve(data,
         date.col = "dates",
         time.period = "month",
         xlab = "Month",
         angle = 0)

epicurve(data,
         date.col = "dates",
         time.period = "month",
         shade.by = "sex",
         xlab = "Month",
         angle = 0)

epicurve(data,
         date.col = "dates",
         time.period = "month",
         fill.by = "sex",
         xlab = "month",
         angle = 0)

epicurve(data,
         date.col = "dates",
         fill.by = "conf",
         split.by = "sex")

epicurve(data,
         date.col = "dates",
         time.period = "month",
         start.at = "2014-01-01",
         stop.at = "2016-04-20",
         fill.by = "sex",
         split.by = NULL,
         shade.by = "conf",
         xlab=NULL,
         ylab="Count",
         fill.by.legend.title = "Sex",
         shade.by.legend.title = NULL,
         angle = 0 ,
         col.pal = 6,
         label.breaks = 0,
         epi.squares = FALSE,
         na.rm = TRUE)

data$dates.year.month = factor(format(data$dates, "%Y_%m"),
                               levels = unique(format(seq(min(data$dates),
                                                          max(data$dates), 1), "%Y_%m")))

epicurve(x = data,
         date.col = "dates.year.month",
         time.period = "use.date.col.as.is",
         start.at = "2015-02-01",
         stop.at = "2015-06-22",
         fill.by ="status",
         split.by = NULL,
         shade.by = NULL,
         xlab = "Year_week",
         ylab="Count",
         fill.by.legend.title = "",
         shade.by.legend.title = NULL,
         angle = 90,
         col.pal = 1,
         label.breaks = 0,
         epi.squares = TRUE,
         na.rm = TRUE)

DanielGardiner/EpiFunc documentation built on July 25, 2019, 10:53 p.m.