-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinitialize_data.R
executable file
·142 lines (135 loc) · 5.1 KB
/
initialize_data.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
###################### Initialize data to avoid error sometimes ###########
setwd("/media/herimanitra/Document/IPM_sentinelle/sentinel_hrmntr 291115/Sentinel")
source("libraries.R")
cat('connect to the server...')
sentinel <- src_postgres(dbname="***",
host = "***",
user = "***",
password = "***")
data_iri_env<-src_postgres(dbname="***",
host="***",
port=000,
user="***",
password="***")
conn_hfi <- src_postgres(dbname="***",
host = "***",
user = "***",
password = "***")
cat('DONE\n')
cat("retrieve and convert PaluConf into a dataframe...")
PaluConf= tbl(sentinel,
build_sql("SELECT * FROM ",
"crosstab_paluconf_format"))
PaluConf= PaluConf %>% data.frame()
cat("DONE\n")
cat("save PaluConf on disk...")
fwrite(PaluConf,"data/PaluConf.csv")
cat("DONE\n")
############################################################################
cat("retrieve and convert Consultations into a dataframe...")
Consultations= tbl(sentinel,
build_sql("SELECT * FROM ",
"crosstab_nxconslttotal_format"))
#transform into data.table:
Consultations= Consultations %>% data.frame()
cat("DONE\n")
cat("save Consultations on disk...")
fwrite(Consultations,"data/Consultations.csv")
cat("DONE\n")
###########################################################################
cat("retrieve and convert SyndF into a dataframe...")
SyndF=tbl(sentinel,
build_sql("SELECT * FROM ",
"crosstab_syndf_format"))
SyndF= SyndF %>% data.frame()
cat("DONE\n")
cat("save SyndF on disk...")
fwrite(SyndF,"data/SyndF.csv")
cat("DONE\n")
##########################################################################
cat("retrieve and convert Diarrh into a dataframe...")
Diarrh=tbl(sentinel,
build_sql("SELECT * FROM ",
"crosstab_diarrh_format"))
Diarrh= Diarrh %>% data.frame()
cat("DONE\n")
cat("save Diarrh on disk...")
fwrite(Diarrh,"data/Diarrh.csv")
cat("DONE\n")
#####################################################
cat("retrieve and convert Diarrh_feb into a dataframe...")
Diarrh_feb=tbl(sentinel,
build_sql("SELECT * FROM ",
"crosstab_diarrhfeb_format"))
Diarrh_feb= Diarrh_feb %>% data.frame()
cat("DONE\n")
cat("save Diarrh_feb on disk...")
fwrite(Diarrh_feb,"data/Diarrh_feb.csv")
cat("DONE\n")
######################################################
cat("retrieve and convert arbosusp into a dataframe...")
arbosusp=tbl(sentinel,build_sql("SELECT * FROM ","crosstab_arbosusp_format"))
arbosusp= arbosusp %>% data.frame()
cat("DONE\n")
cat("save arbosusp on disk...")
fwrite(arbosusp,"data/arbosusp.csv")
cat("DONE\n")
#####################################################
cat("retrieve and convert ILI into a dataframe...")
ili=tbl(sentinel,
build_sql("SELECT * FROM ",
"crosstab_grippsusp_autrvirresp_format"))
ili= ili %>% data.frame()
cat("DONE\n")
cat("save ILI on disk...")
fwrite(ili,"data/ili.csv")
cat("DONE\n")
######################################################
cat("retrieve and convert HFI into a dataframe...")
hfi= tbl(conn_hfi,
build_sql("SELECT * FROM ","crosstab_iri_caid"))
hfi= hfi %>% data.frame()
cat("DONE\n")
cat("save HFI on disk...")
fwrite(hfi,"data/hfi.csv")
cat("DONE\n")
###################################################
cat("retrieve and convert tdr_eff into a dataframe...")
tdr_eff= tbl(sentinel,
build_sql('SELECT "Date" AS "Date","SyndF","TestPalu","Centre2" AS "sites","Annee","Semaine","ArboSusp","GrippSusp","AutrVirResp","NxConsltTotal" FROM ',
"vue_csb_sms_centre_format"))
tdr_eff= tdr_eff %>% data.frame()
cat("DONE\n")
cat("save tdr_eff on disk...")
fwrite(tdr_eff,"data/tdr_eff.csv")
cat("DONE\n")
###################################################
cat("retrieve and convert palu_autoch into a dataframe...")
palu_autoch=tbl(sentinel,
build_sql("SELECT * FROM ",
"crosstab_autoch_format"))
palu_autoch= palu_autoch %>% data.frame()
cat("DONE\n")
cat("save palu_autoch on disk...")
fwrite(palu_autoch,"data/palu_autoch.csv")
cat("DONE\n")
######################################################
cat("retrieve and convert PFA into a dataframe...")
pfa= tbl(sentinel,
build_sql("SELECT * FROM ",
"crosstab_pfa_format"))
pfa= pfa %>% data.frame()
cat("DONE\n")
cat("save PFA on disk...")
fwrite(pfa,"data/pfa.csv")
cat("DONE\n")
######################################################
cat("retrieve and convert missing_sent into a dataframe...")
missing_sent= tbl(sentinel,
build_sql("SELECT * FROM ",
"vue_csb_sms_centre_format"))
missing_sent= missing_sent %>% data.frame()
cat("DONE\n")
cat("save missing_sent on disk...")
fwrite(missing_sent,"data/missing_sent.csv")
cat("DONE\n")