-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path00_Prepare_figures.R
57 lines (45 loc) · 1.68 KB
/
00_Prepare_figures.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
library(pulsosocialcolombia)
library(here)
library(googlesheets4)
library(tidyverse)
dic_map <-"https://docs.google.com/spreadsheets/d/1ZEqO-bYWPYixr2xI6fNeW4MCEeyZYqFoIRUKllhbeU8/edit?usp=sharing"
#### Get the file
codvars <- read_sheet(dic_map, sheet = "Vars", col_names = TRUE)
# for (i in c(320:331)){
for (i in codvars$var_id) {
# i <- 309
# graph options
w <- 7*1.5
h <- 4*1.5
dpi <- 300
d <- codvars[codvars$var_id==i,]
print(i)
### Trend
if (d$fig_trend==1) {
fl <- paste0(here(),"/img/","var_",d$var_id,"_trend",".png", sep="")
try(ggsave(fl,print(pulso_trend(i,"print")),dpi = dpi, width = w, height = h))
}
#### Static
fl <- paste0(here(),"/img/","var_",d$var_id,"_static",".png", sep="")
try(ggsave(fl,print(pulso_static(i,"print")),dpi = dpi, width = w, height = h))
#### Map
if (d$fig_map==1) {
fl <- paste0(here(),"/img/","var_",d$var_id,"_map",".png", sep="")
try(ggsave(fl,print(pulso_map(i,"print")),dpi = dpi, width = w, height = h))
}
#### Map change
if (d$fig_map==1 & d$fig_trend==1) {
fl <- paste0(here(),"/img/","var_",d$var_id,"_map_change",".png", sep="")
try(ggsave(fl,print(pulso_map_change(i,"print")),dpi = dpi, width = w, height = h))
}
### Scatter (level)
if(d$fig_scatter==1){
fl <- paste0(here(),"/img/","var_",d$var_id,"_scatter",".png", sep="")
try(ggsave(fl,print(pulso_scatter(i,"print")),dpi = dpi, width = w, height = h))
}
### Scatter (time)
if (d$fig_scatter_time==1){
fl <- paste0(here(),"/img/","var_",d$var_id,"_scatter_time",".png", sep="")
try(ggsave(fl,print(pulso_scatter_time(i,"print")),dpi = dpi, width = w, height = h))
}
}