-
Notifications
You must be signed in to change notification settings - Fork 0
/
stegen_descrip.R
72 lines (49 loc) · 1.58 KB
/
stegen_descrip.R
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
# Stegen case study
# Example of solution R-script
# EpiConcept
# February 2012
# Descriptive analysis
# Esther Kissling - Gilles DESVE
# R-code written by Alexander Spina September 2018
#### Reading in files ####
load("stegen1.Rda")
#### Person ####
# specify the variable in quotations and the dataset to use
big.table(var = "sex", data = tira.data)
# summary of age
summary(tira.data$age)
# summary of age by sex
# use the aggregate function to group by sex
# sex must be as a list
# specify the function you would like to use (summary)
aggregate(tira.data$age, by = list(tira.data$sex), FUN = summary)
#Plot a histogram of age
#you can specify a bar for each age with "breaks"
#you can set your x axis from 0-100 using "xlim"
hist(tira.data$age,
xlab = "Age",
ylab = "Count",
breaks = 100,
xlim = c(0, 100)
)
# save histogram of age as a png file
dev.copy(png,'age.png')
dev.off()
#### 2 different age groups: ####
big.table("agegroup", tira.data)
big.table("ill", tira.data)
big.table("dateonset", tiradata[tira.data$ill == 1])
#### epidemic curve ####
# Load the epiconcept epicurve function
library(EpiCurve)
# subset data so only have ill and non missing
tester <- tira.data[which(tira.data$ill == "Yes" &
!is.na(tira.data$dateonset)), ]
#use epicurve function to plot daily
EpiCurve(x = tester,
date = "dateonset",
period = "day",
xlabel = sprintf("From %s to %s",
min(tester$dateonset, na.rm = T),
max(tester$dateonset, na.rm = T))
)