-
Notifications
You must be signed in to change notification settings - Fork 0
/
cleaning_epidemiological_data_inR.R
73 lines (35 loc) · 1.11 KB
/
cleaning_epidemiological_data_inR.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
72
73
library(cleanepi)
data<- read_csv(
here::here("data","simulated_ebola_2.csv")
)
#View data
View(data)
#viewing names of the columns
names(data)
#Clean column names
data %>%
cleanepi::standardize_column_names()
cleaned_data<- data %>%
cleanepi::standardize_column_names()
view(cleaned_data)
#Renaming columns
cleaned_data<- data %>%
cleanepi::standardize_column_names() %>%
cleanepi::standardize_column_names(
rename = c("index"= "x1")) %>%
#remove constraints,1 means 100% entries of the col are the same
cleanepi::remove_constants(cutoff = 1) %>%
#remove duplicates
cleanepi::remove_duplicates() %>%
#replace missing values
cleanepi::replace_missing_values(
na_strings = "") %>%
cleanepi::convert_to_numeric(target_columns = "age") %>%
cleanepi::standardize_dates(
target_columns = c("date_onset","date_sample"),
timeframe = c(as.Date("2014-01-01"), as.Date("2016-12-30"))
) %>%
#PRINT REPORT
cleanepi::print_report()
#viewing cleaned data
view(cleaned_data)