-
Notifications
You must be signed in to change notification settings - Fork 2
/
01-epi_descriptiva.R
57 lines (42 loc) · 1.75 KB
/
01-epi_descriptiva.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
#' tutorial fuente
#' https://www.reconlearn.org/post/real-time-response-1.html
#'
# paquetes ----------------------------------------------------------------
library(tidyverse)
library(readxl)
library(lubridate)
library(naniar)
library(compareGroups)
# importar ----------------------------------------------------------------
#https://github.com/reconhub/learn/raw/master/static/data/linelist_20140701.xlsx
casos <- read_xlsx("data-raw/linelist_20140701.xlsx")
casos %>% glimpse()
# limpiar -----------------------------------------------------------------
casos_limpio <- casos %>%
mutate_at(.vars = vars(starts_with("date_")),.funs = ymd)
# evaluar -----------------------------------------------------------------
casos_limpio %>% miss_var_summary()
# guardar -----------------------------------------------------------------
write_rds(casos_limpio,"data/casoslimpio_20190916.rds")
# en tiempo ---------------------------------------------------------------
casos_limpio %>%
ggplot(aes(date_of_onset)) +
geom_histogram(binwidth = 7,color="white") +
scale_x_date(date_breaks = "7 day",date_labels = "%b-%d") +
theme_bw() +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
# en espacio --------------------------------------------------------------
casos_limpio %>%
mutate(epiweek=epiweek(date_of_onset)) %>%
ggplot(aes(x = lon,y = lat,colour=date_of_onset)) +
geom_point() +
scale_color_gradient(low = "red",high = "yellow",trans = "date") +
theme_bw() +
facet_wrap(~epiweek)
# table -------------------------------------------------------------------
casos_limpio %>%
mutate(hospital=fct_infreq(hospital),
outcome=fct_infreq(outcome)) %>%
select(outcome:hospital) %>%
compareGroups(~.,data = .) %>%
createTable()