forked from dnme-minturdep/dnme_apps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathareas_protegidas.Rmd
758 lines (706 loc) · 32.2 KB
/
areas_protegidas.Rmd
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
---
title: "Áreas Protegidas"
description: "Resumen de los últimos datos de visitas a Parques Nacionales y Áreas Protegidas Provinciales según origen (condición de residencia) de los visitantes. La información se obtiene a partir de datos relevados por la Administración de Parques Nacionales y organismos provinciales."
output: distill::distill_article
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = F, message = F, warning = F,
fig.align = 'left')
options(scipen = 9999)
library(gt) # Easily Create Presentation-Ready Display Tables, CRAN v0.2.2
library(tidyverse) # Easily Install and Load the 'Tidyverse', CRAN v1.3.0
library(lubridate) # Make Dealing with Dates a Little Easier, CRAN v1.7.9
library(extrafont) # Tools for using fonts, CRAN v0.17 # Tools for using fonts, CRAN v0.17
library(ggtext)
library(glue)
library(janitor)
library(readxl)
library(plotly)
library(herramientas)
library(comunicacion)
Sys.setlocale("LC_TIME", "es_AR.UTF-8")
```
```{r }
# Definir mes / trimestre / año de referencia para títulos ####
fecha <- "2024-12-01"
mes <- "Diciembre"
anio <- "2024"
parques_sin_dato <- c("pizarro", "ansenuza", "formosa", "traslasierra")
#parques <- c("el leoncito", "sierra de las quijadas")
# PALETAS Y FUENTES ---------------------------------------------------------
# Paleta colores Presidencia
cols_arg <- "#37BBED" # Celeste Institucional
#Secundarios
cols_arg2 <- c("#EE3D8F", # "ROJO"
"#50B8B1", # "VERDE"
"#F7941E","#FFD100","#D7DF23", "#9283BE")
#Fuente
familia_fuente <- "Encode Sans Normal"
# fonttable() %>%
# as_tibble() %>%
# filter(str_detect(FamilyName, "Encode Sans Normal"),
# Bold == TRUE) %>%
# pull(FamilyName) %>%
# unique()
# Estilo de graficos
theme_imet <- function() {
theme(legend.position = "none",
text = element_text(family = familia_fuente))
}
#gs4_deauth() # Importar sheet de google sin interactividad de autorizacion
# #Configuración tags htmls
# meta() %>%
# meta_description(
# glue("Visitas a Parques Nacionales en {mes} {anio}")
# ) %>%
# meta_viewport() %>%
# meta_social(
# title = glue("Parques Nacionales {mes} {anio}"),
# image = "https://upload.wikimedia.org/wikipedia/commons/8/8e/Ministerio_de_Turismo_y_Deportes_arg.png",
# og_author = c("Dirección de Mercados y Estadísticas",
# "Dirección Nacional de Calidad Turística",
# "Secretaría de Turismo, Ambiente y Deportes")
# )
```
### (Publicado en `r format(Sys.time(), '%B %Y')` con datos actualizados a `r paste(mes," de ",anio)`)
<br>
## Parques Nacionales
```{r}
#Importo datos
# parques_nacionales <- #read_file_srv("/srv/DataDNMYE/areas_protegidas/areas_protegidas_nacionales/pivot_#pn.xlsx",
# sheet = "base PN")
parques_nacionales <- read_file_srv("/srv/DataDNMYE/areas_protegidas/areas_protegidas_nacionales/pivot_pn.xlsx", sheet= 2)%>%
filter(parque_nacional != "nahuel huapi") %>%
mutate(parque_nacional = ifelse(parque_nacional == "nahuel huapi 3p", "nahuel huapi",
parque_nacional))
# parques_nacionales <- read_sheet("https://docs.google.com/spreadsheets/d/1ZM7PfvY16tImMcFKUj0fCn6ASc1yxlye/edit#gid=1610808314")
#parques_nacionales <- read.xlsx("data/Pivot_PN_20201125.xlsx",sheet="base PN 2008_2020")
```
```{r}
#Agrego columna con número de mes
tabla_parques <- parques_nacionales %>%
mutate(Mes = str_to_title(Mes)) %>%
left_join(data.frame(Mes = c("Enero","Febrero","Marzo","Abril","Mayo","Junio",
"Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"),
month = c(1:12)))
# tabla_parques <- tabla_parques %>% mutate(
# visitantes = case_when(
# Mes %in% c("Abril", "Mayo", "Junio") & anio == 2020 ~ `is.na<-`(visitantes),
# TRUE ~ visitantes)
# )
```
```{r}
data_tabla_1 <- tabla_parques %>%
mutate(visitantes = ifelse(parque_nacional %in% parques_sin_dato &
Mes == str_to_sentence(.GlobalEnv$mes) & anio == as.numeric(.GlobalEnv$anio)-1,
0, visitantes)) %>%
group_by(anio,month,residencia) %>%
summarise(n = sum(visitantes,na.rm = T)) %>% ungroup() %>%
arrange(anio,month) %>%
group_by(anio,residencia) %>%
mutate(acum = cumsum(n)) %>% ungroup() %>%
group_by(residencia) %>%
mutate(var.n = n/lag(n,12)-1,var.acum = acum/lag(acum,12)-1) %>%
mutate(residencia = case_when(residencia == "no residentes" ~ "no_residentes",
TRUE ~ residencia),
period = ymd(as.character(glue::glue("{anio}/{month}/01")))) %>%
pivot_wider(.,names_from="residencia",values_from = c("n","acum","var.n","var.acum")) %>%
mutate(total = n_no_residentes + n_residentes,
var.total = total/lag(total,12)-1) %>%
group_by(anio) %>%
mutate(total.acum = cumsum(total)) %>% ungroup() %>%
mutate(var.tot.acum = total.acum/lag(total.acum,12)-1) %>%
mutate(
var.total = case_when(
is.infinite(var.total) ~ `is.na<-`(var.total),
TRUE ~ var.total),
var.n_no_residentes = case_when(
is.infinite(var.n_no_residentes) ~ `is.na<-`(var.n_no_residentes),
TRUE ~ var.n_no_residentes),
var.n_residentes = case_when(
is.infinite(var.n_residentes) ~ `is.na<-`(var.n_residentes),
TRUE ~ var.n_residentes)
)
tabla.1.mes <- data_tabla_1 %>%
select("anio","month",period,total,n_no_residentes,n_residentes,var.n_no_residentes,var.n_residentes,var.total) %>%
mutate(part.res = n_residentes/total,
part.no.res = n_no_residentes/total,
periodo = paste0(mes," ",anio)) #SOLO ENERO
tabla.1.acum <- data_tabla_1 %>%
select("anio","month",period,total.acum,acum_residentes,acum_no_residentes,
var.acum_no_residentes,var.acum_residentes,var.tot.acum) %>%
rename(total = total.acum, n_no_residentes = acum_no_residentes, n_residentes = acum_residentes,
var.n_no_residentes = var.acum_no_residentes,var.n_residentes = var.acum_residentes,
var.total = var.tot.acum) %>%
mutate(part.res = n_residentes/total,
part.no.res = n_no_residentes/total,
periodo = paste0("Acum. ", anio))
```
<br>
En el mes de `r mes` se registraron `r format(round(pull(tabla.1.mes[tabla.1.mes$period == fecha,"total"]),0),big.mark=".")` visitas a Parques Nacionales, con `r format(round(pull(tabla.1.mes[tabla.1.mes$period == fecha,"n_residentes"]),0),big.mark=".")` visitas de residentes y `r format(round(pull(tabla.1.mes[tabla.1.mes$period == fecha,"n_no_residentes"]),0),big.mark=".")` de no residentes.
<br>
```{r}
# En el acumulado del año las visitas suman un total de `r format(pull(tabla.1.acum[tabla.1.mes$period == fecha,"total"]),big.mark=".")` (`r format(pull(tabla.1.acum[tabla.1.acum$period == fecha,"n_residentes"]),big.mark=".")` residentes y `r format(pull(tabla.1.acum[tabla.1.acum$period == fecha,"n_no_residentes"]),big.mark=".")` no residentes), lo que implica una variación de `r format(round(100*pull(tabla.1.acum[tabla.1.acum$period == fecha,"var.total"]),1),decimal.mark=",")`% con respecto al mismo período del año anterior.
#tabla_1 <-
tabla.1.mes %>% bind_rows(tabla.1.acum) %>%
filter(period == fecha) %>%
#filter(periodo != "Acum. 2021") %>% #SOLO PARA ENERO
mutate_at(.vars = c("n_residentes",
"n_no_residentes",
"total"),
.funs = ~ .x/1000) %>%
select(periodo,total,n_residentes,n_no_residentes,7:(ncol(tabla.1.mes)-1)) %>%
mutate(periodo = paste0(periodo, "*")) %>%
gt() %>%
fmt_number(columns = c(2,3,4), decimals = 1, sep_mark = ".", dec_mark = ",") %>%
fmt_percent(columns = c(5,6,7,8,9), decimals = 1, sep_mark = ".", dec_mark = ",") %>%
#cols_align(
# align = "center",
#columns = vars(total,var.total,n_residentes,var.n_residentes,part.res, n_no_residentes, var.n_no_residentes,part.no.res
#))%>%
cols_label(
total = md("Miles<br>de<br>Visitas") ,
n_residentes = md("Miles<br>de<br>Visitas") ,
n_no_residentes = md("Miles<br>de<br>Visitas") ,
var.n_no_residentes = md("Var. i.a.<br> %") ,
var.n_residentes = md("Var i.a.<br> %") ,
var.total = md("Var. i.a.<br> %") ,
part.res = md("Part.<br>%"),
part.no.res = md("Part.<br>%"),
periodo = md("Período")
) %>%
tab_style(
style = list(
cell_text(color = cols_arg2[1]),
cell_text(weight = "bold")
),
locations = cells_body(
columns = vars(var.total),
rows = var.total< 0)
) %>%
tab_style(
style = list(
cell_text(color = cols_arg2[2]),
cell_text(weight = "bold")
),
locations = cells_body(
columns = vars(var.total),
rows = var.total > 0)
) %>%
tab_style(
style = list(
cell_text(color = cols_arg2[2]),
cell_text(weight = "bold")
),
locations = cells_body(
columns = vars(var.n_no_residentes),
rows = var.n_no_residentes > 0)
) %>%
tab_style(
style = list(
cell_text(color = cols_arg2[1]),
cell_text(weight = "bold")
),
locations = cells_body(
columns = vars(var.n_no_residentes),
rows = var.n_no_residentes < 0)
) %>%
tab_style(
style = list(
cell_text(color = cols_arg2[1]),
cell_text(weight = "bold")
),
locations = cells_body(
columns = vars(var.n_residentes),
rows = var.n_residentes < 0)
) %>%
tab_style(
style = list(
cell_text(color = cols_arg2[2]),
cell_text(weight = "bold")
),
locations = cells_body(
columns = vars(var.n_residentes),
rows = var.n_residentes > 0)
) %>%## AGRUPAMIENTO DE COLUMNAS POR VARIABLE DE INTERES
tab_spanner(
label = md("**TOTAL**"),
columns = vars(total,
var.total)) %>%
tab_spanner(
label = md("**RESIDENTES**"),
columns = vars(n_residentes,
var.n_residentes,
part.res)) %>%
tab_spanner(
label = md("**NO RESIDENTES**"),
columns = vars(n_no_residentes,
var.n_no_residentes,
part.no.res)
) %>%
tab_header(title="Visitas a Parques Nacionales") %>%
cols_align(
align = "center") %>%
fmt_missing(columns = 1:8,
missing_text = "///") %>%
tab_source_note(glue("*: Dato provisorio."))
# tab_source_note(glue("///: Dato que no corresponde mostrar debido a la naturaleza de las cosas."))
#setwd("Salidas/")
# htmltools::save_html(html = tabla_1, file = "tabla_1_PN.html")
# webshot::webshot("tabla_1_PN.html", file="out.png", delay=3,vwidth =700 ,vheight = 300)
```
<br>
```{r}
data_grafico_1 <- tabla_parques %>%
group_by(anio,month,residencia) %>%
summarise(n = sum(visitantes,na.rm = T)) %>% ungroup() %>%
arrange(anio,month) %>%
group_by(anio,residencia) %>%
mutate(acum = cumsum(n)) %>% ungroup() %>%
group_by(residencia) %>%
mutate(var.n = n/lag(n,12)-1,var.acum = acum/lag(acum,12)-1) %>%
mutate(residencia = case_when(residencia == "no residentes" ~ "no_residentes",
TRUE ~ residencia),
period = ymd(as.character(glue::glue("{anio}/{month}/01")))) %>%
pivot_wider(.,names_from="residencia",values_from = c("n","acum","var.n","var.acum")) %>%
mutate(total = n_no_residentes + n_residentes,
var.total = total/lag(total,12)-1) %>%
group_by(anio) %>%
mutate(total.acum = cumsum(total)) %>% ungroup() %>%
mutate(var.tot.acum = total.acum/lag(total.acum,12)-1) %>%
mutate(
var.total = case_when(
is.infinite(var.total) ~ `is.na<-`(var.total),
TRUE ~ var.total),
var.n_no_residentes = case_when(
is.infinite(var.n_no_residentes) ~ `is.na<-`(var.n_no_residentes),
TRUE ~ var.n_no_residentes),
var.n_residentes = case_when(
is.infinite(var.n_residentes) ~ `is.na<-`(var.n_residentes),
TRUE ~ var.n_residentes)
) %>%
select("anio","month",period,total,n_no_residentes,n_residentes,var.n_no_residentes,var.n_residentes,var.total) %>%
mutate(part.res = n_residentes/total,
part.no.res = n_no_residentes/total,
periodo = paste0(mes," ",anio))
#Gráfico1
data_grafico_1 <- data_grafico_1 %>% select(period,total) %>%
mutate(total = round(total/1000,1)) %>%
filter(period >= "2018-01-01" & period <= fecha)
grafico_1 <- ggplot(data_grafico_1) +
geom_hline(yintercept = 0, color = "black", alpha =0.7, size = 0.5) +
geom_line(aes(period, total),
size = 1, color = cols_arg2[6], alpha = .5) +
geom_point(aes(period, total,
text=paste('fecha: ',"",format(period,"%b-%y")
,'<br>visitas: ',format(round(total,2),big.mark=".",decimal.mark=","),' m')),
size = 1.1, color = cols_arg2[6]) +
# geom_text(data = filter(data_grafico_1, (period == fecha)),
# aes(x = period, y = total, label = format(total,decimal.mark = ",")),
# color = cols_arg2[6],
# size = 2,
# fontface = "bold",
# vjust = -0.5,
# family = familia_fuente) +
scale_x_date(date_breaks = "1 months",
date_labels = "%b%y",
expand = c(0,15)) +
scale_y_continuous(breaks = seq(0, 2000, by = 100),
labels = scales::number_format(big.mark = ".")) +
theme_minimal() +
theme_imet() +
theme(
plot.subtitle = element_markdown(size = ),
axis.text.x = element_text(size = 6, angle = 90),
axis.text.y = element_text(size = 6),
panel.grid.major = element_line(colour="grey90",size = rel(0.5)),
panel.grid.minor = element_blank())+
coord_cartesian(clip = 'off')+
labs(x="",y="",
title = "Visitas en Parques Nacionales",
subtitle = tolower(glue("**En miles. enero 2018 - {mes} {anio}**")))
ggplotly(grafico_1,tooltip = "text")
```
```{r include=F, eval=F}
#Grafico 2
data_grafico_2 <- tabla.1.mes %>% select(period,"residentes" = var.n_residentes,"no_residentes"=var.n_no_residentes) %>%
filter(period >= "2018-01-01" & period <= fecha) %>%
pivot_longer(cols=c("residentes","no_residentes"))%>%
filter(period >= "2018-01-01" & period <= fecha)
grafico_2 <- ggplot(data = data_grafico_2, aes(x = period, y = value)) +
geom_hline(yintercept = 0, color = "black", alpha = 0.6) +
geom_line( aes(color = name),
size = 1, alpha = .5) +
geom_point(data = data_grafico_2, aes(color = name,
text=paste('fecha: ',"",format(period,"%b-%y")
,'<br>variación: ',format(round(100*value,1),big.mark=".",decimal.mark=","),'%',
'<br>origen: ',name)),
size = 1.1) +
# geom_text(data = filter(data_grafico_2, (period == fecha)),
# aes(x = period, y = value,
# label =paste0(format(round(100*value,0),decimal.mark = ","),"%"), colour = name,
# vjust = ifelse(name == "var.n_residentes", -0.5, 1.2)),
# size = 2,
# fontface = "bold",
# family = familia_fuente)+
scale_color_manual(values = c("no_residentes" = cols_arg2[6],
"residentes" = cols_arg2[2])) +
scale_x_date(date_breaks = "1 months",
date_labels = "%b%y",
expand = c(0,20)) +
theme_minimal() +
theme(
text = element_text(family = familia_fuente),
plot.title = element_markdown(size = 13),
plot.subtitle = element_markdown(size = 10, face = "bold"),
plot.caption = element_markdown(size = 7),
strip.text.y = element_text(size = 6, face = "bold"),
axis.text.x = element_text(size = 6, angle = 90),
axis.text.y = element_text(size = 6),
panel.grid.minor.x = element_blank(),
legend.position = "none",
strip.placement = "outside"
) +
coord_cartesian(clip = 'off')+
scale_y_continuous(labels = scales::percent_format())+
labs(x="",y="",
title = "Variación porcentual interanual de las visitas en Parques Nacionales",
subtitle = tolower(glue("enero 2018 - {mes} {anio}. <span style='color:{cols_arg2[2]}'>residentes</span> y <span style='color:{cols_arg2[6]}'>no residentes")))
ggplotly(grafico_2,tooltip="text")
```
<br>
```{r}
### Tabla 2 ----
data_tabla_2 <- tabla_parques %>%
mutate(visitantes = coalesce(visitantes, 0)) %>%
mutate(visitantes = ifelse(parque_nacional %in% parques_sin_dato &
Mes == str_to_sentence(.GlobalEnv$mes) & anio == as.numeric(.GlobalEnv$anio)-1,
NA_real_, visitantes)) %>%
group_by(anio, parque_nacional, residencia) %>%
mutate(acumulado = cumsum(visitantes)) %>% ungroup() %>%
filter(anio >= 2023 & month == month(fecha)) %>%
pivot_wider(names_from = c("anio", "residencia"), values_from = c(visitantes, acumulado)) %>%
mutate(across(where(is.numeric), ~ coalesce(.x, 0))) %>%
clean_names() %>%
mutate(visitantes_2024_total = visitantes_2024_residentes + visitantes_2024_no_residentes,
visitantes_2023_total = visitantes_2023_residentes + visitantes_2023_no_residentes,
# visitantes_2020_total = visitantes_2020_residentes + visitantes_2020_no_residentes,
acumulado_2024_total = acumulado_2024_residentes + acumulado_2024_no_residentes,
acumulado_2023_total = acumulado_2023_residentes + acumulado_2023_no_residentes,
# acumulado_2020_total = acumulado_2020_residentes + acumulado_2020_no_residentes,
participacion = round(acumulado_2023_total / sum(acumulado_2023_total), 3)) %>%
# mutate(across(where(is.numeric), ~ case_when(parque_nacional %in% parques ~ NA_real_,
# TRUE ~ .))) %>%
arrange(-participacion) %>%
mutate(var_ia_visitantes_2024_tot = visitantes_2024_total/visitantes_2023_total-1,
var_ia_visitantes_res = visitantes_2024_residentes/visitantes_2023_residentes-1,
var_ia_visitantes_no_res = visitantes_2024_no_residentes/visitantes_2023_no_residentes-1,
var_ia_acumulado_total = acumulado_2024_total/ acumulado_2023_total-1) %>%
mutate(across(where(is.numeric), ~ coalesce(.x, 0))) %>%
arrange(-acumulado_2024_total) %>%
mutate(orden = rank(-acumulado_2024_total),
presentacion = case_when(orden <= 25 ~ parque_nacional,
TRUE ~ "Resto")) %>%
mutate(across(where(is.numeric), ~ case_when(is.infinite(.) ~ NA_real_,
TRUE ~ .)))
```
```{r}
resto_pn <- data_tabla_2 %>%
filter(presentacion == "Resto") %>%
summarise_if(is.numeric, sum) %>%
mutate(var_ia_visitantes_2024_tot = visitantes_2024_total/visitantes_2023_total-1,
var_ia_visitantes_res = visitantes_2024_residentes/visitantes_2023_residentes-1,
var_ia_visitantes_no_res = visitantes_2024_no_residentes/visitantes_2023_no_residentes-1,
var_ia_acumulado_total = acumulado_2024_total/acumulado_2023_total-1,
parque_nacional = "Resto")
# mutate(
# var_ia_visitantes_2021_tot = `is.na<-`(var_ia_visitantes_2021_tot),
# var_ia_visitantes_res = `is.na<-`(var_ia_visitantes_res),
# var_ia_visitantes_no_res = `is.na<-`(var_ia_visitantes_no_res)
# )
data_tabla_2 <- data_tabla_2 %>%
filter(presentacion != "Resto") %>%
bind_rows(resto_pn) %>%
mutate(participacion = round(acumulado_2024_total / sum(acumulado_2024_total), 3)) %>%
select(parque_nacional,
visitantes_2024_total, var_ia_visitantes_2024_tot,
visitantes_2024_residentes, var_ia_visitantes_res,
visitantes_2024_no_residentes, var_ia_visitantes_no_res,
acumulado_2024_total, var_ia_acumulado_total,
participacion)
#tabla2 <-
data_tabla_2 %>%
mutate(parque_nacional = str_to_title(parque_nacional)) %>%
#select(-var_ia_acumulado_total,-acumulado_2021_total) %>%
gt(rowname_col = "parque_nacional") %>% #SOLO EN ENERO
cols_label(
visitantes_2024_total = md("Visitas"),
var_ia_visitantes_2024_tot = md("Var % i.a."),
visitantes_2024_residentes = md("Visitas") ,
var_ia_visitantes_res = md("Var % i.a."),
visitantes_2024_no_residentes = md("Visitas"),
var_ia_visitantes_no_res = md("Var % i.a."), #SOLO EN ENERO
acumulado_2024_total = md("Visitas"), #SOLO EN ENERO
var_ia_acumulado_total = md("Var % i.a."),
participacion = md("Participación %")
) %>%
fmt_number(columns = c(2,4,6,8), decimals = 0, sep_mark = ".", dec_mark = ",") %>% #CAMBIAR, SOLO ENERO
fmt_percent(columns = c(3,5,7,9,10), decimals = 1, sep_mark = ".", dec_mark = ",") %>%
cols_align(
align = "center",
columns = vars(visitantes_2024_total, var_ia_visitantes_2024_tot, visitantes_2024_residentes,
var_ia_visitantes_res, visitantes_2024_no_residentes, var_ia_visitantes_no_res,
acumulado_2024_total, var_ia_acumulado_total, #SOLO ENERO
participacion)
) %>%
opt_table_font(
font = list(
google_font(name = "Encode Sans")
)
) %>%
tab_header(
title = "RANKING DE LOS PARQUES NACIONALES CON MAYOR CANTIDAD DE VISITAS",
#subtitle = md(glue("**Pasajeros, asientos y vuelos. {mes} {anio} y acumulado {anio}**"))
) %>%
tab_source_note(
source_note = md(
"**Fuente**: Dirección de Mercados y Estadísticas, Dirección Nacional de Calidad Turística, Secretaría de Turismo, Ambiente y Deportes, en base a la informacion suministrada por la Dirección Nacional de Uso Público, APN")
) %>%
# tab_source_note(
# source_note = md(
# "**Nota**: El PN Ciervo de los pantanos se cerró a la visita por obras")
# ) %>%
tab_style(
style = list(
cell_text(color = "#EE3D8F"),
cell_text(weight = "bold")
),
locations = cells_body(
columns = vars(var_ia_visitantes_2024_tot),
rows = var_ia_visitantes_2024_tot < 0)
) %>%
tab_style(
style = list(
cell_text(color = "#50B8B1"),
cell_text(weight = "bold")
),
locations = cells_body(
columns = vars(var_ia_visitantes_2024_tot),
rows = var_ia_visitantes_2024_tot > 0)
) %>%
tab_style(
style = list(
cell_text(color = "#EE3D8F"),
cell_text(weight = "bold")
),
locations = cells_body(
columns = vars(var_ia_visitantes_res),
rows = var_ia_visitantes_res < 0)
) %>%
tab_style(
style = list(
cell_text(color = "#50B8B1"),
cell_text(weight = "bold")
),
locations = cells_body(
columns = vars(var_ia_visitantes_res),
rows = var_ia_visitantes_res > 0)
) %>%
tab_style(
style = list(
cell_text(color = "#EE3D8F"),
cell_text(weight = "bold")
),
locations = cells_body(
columns = vars(var_ia_visitantes_no_res),
rows = var_ia_visitantes_no_res < 0)
) %>%
tab_style(
style = list(
cell_text(color = "#50B8B1"),
cell_text(weight = "bold")
),
locations = cells_body(
columns = vars(var_ia_visitantes_no_res),
rows = var_ia_visitantes_no_res > 0)
) %>%
tab_style(
style = list(
cell_text(color = "#EE3D8F"),
cell_text(weight = "bold")
),
locations = cells_body(
columns = vars(var_ia_acumulado_total),
rows = var_ia_acumulado_total < 0)
) %>%
tab_style(
style = list(
cell_text(color = "#50B8B1"),
cell_text(weight = "bold")
),
locations = cells_body(
columns = vars(var_ia_acumulado_total),
rows = var_ia_acumulado_total > 0)
) %>% ## AGRUPAMIENTO DE COLUMNAS POR VARIABLE DE INTERES
tab_header(title = toupper(glue("{mes} {anio}"))) %>%
tab_spanner(
label = md(glue("**ACUMULADO {anio}**")),
columns = c(acumulado_2024_total,
var_ia_acumulado_total,
participacion)) %>%
tab_options(column_labels.font.size = 14) %>%
tab_spanner(
label = md("**TOTAL**"),
columns = c(visitantes_2024_total,
var_ia_visitantes_2024_tot #SOLO ENERO
)) %>%
tab_spanner(
label = md("**RESIDENTES**"),
columns = c(visitantes_2024_residentes,
var_ia_visitantes_res)) %>%
tab_spanner(
label = md("**NO RESIDENTES**"),
columns = c(visitantes_2024_no_residentes,
var_ia_visitantes_no_res)) %>%
#tab_header(title = "ACUMULADO 2020")
tab_stubhead(label = md("**Parque Nacional**")) %>%
fmt_missing(columns = 1:10,
missing_text = "///") %>%
sub_zero(columns = 1:10, zero_text = "-") %>%
tab_source_note(glue("///: Dato que no corresponde mostrar debido a la naturaleza de las cosas.")) %>%
# tab_source_note("Los PN Perito Moreno e Isla Pingüino se cierran a la visita desde fines de abril a principios de octubre.") %>%
tab_source_note("Nota: No se recibió información de visitas de los PN Ansenuza, Traslasierra, RN Formosa y la RN Pizarro.")
#tab_source_note("Nota: entre el 22 y 30 de mayo los parques nacionales se cerraron a las visitas (según DI-2021-95-APN-DNO#APNAC) en adhesión a las medidas nacionales (Decreto 334/2021).")
```
## Áreas Protegidas Provinciales
```{r}
months <- data.frame(Mes = c("enero","febrero","marzo","abril","mayo","junio",
"julio","agosto","septiembre","octubre","noviembre","diciembre"),
month = seq(1,12))
### SE LEVANTAN LA BASE DE LAS AP DEL CHUBUT. AJUSTÉ TOMBO Y MARQUES EN FEBRERO 2023 PARA VARACIONES
chubut <- read_file_srv("/srv/DataDNMYE/areas_protegidas/areas_protegidas_provinciales/insumos/base_trabajo/bases_chubut.csv") %>%
filter(Mes != "total") %>%
mutate(Mes = ifelse(Mes=="setiembre", "septiembre", Mes)) %>%
# filter(area_protegida != "Cabo 2B") %>%
left_join(months) %>%
mutate(indice_tiempo = as.Date(paste(anio,month,"01",sep = "-")),
residencia = ifelse(residencia == "no_residentes", "No residentes", "Residentes"),
provincia = "Chubut"
# visitantes = ifelse(area_protegida %in% c("Punta Tombo","Punta Marqués") &
# Mes == mes & anio == 2023, 0, visitantes)
)
#SE LEVANTA LA PIVOT DE ISCHIGUALASTO
sanjuan <-read_file_srv("/srv/DataDNMYE/areas_protegidas/areas_protegidas_provinciales/Base_parq_prov_ischigualasto.xlsx") %>%
rename(indice_tiempo = 1, visitantes = 2) %>%
filter(indice_tiempo != "Total general") %>%
mutate(indice_tiempo = lubridate::ym(indice_tiempo),
Mes = months(indice_tiempo),
anio = year(indice_tiempo),
provincia = "San Juan (Ischigualasto)") %>%
left_join(months)
# A PARTIR DEL 2024 SE ABRIO LA INFORMACIÓN POR CONDICION DE RESIDENCIA, SE LEVANTA LA INFORMACIÓN DE LA MISMA PIVOT EN OTRA SOLAPA
sanjuan_res<-read_file_srv("/srv/DataDNMYE/areas_protegidas/areas_protegidas_provinciales/Base_parq_prov_ischigualasto.xlsx", sheet = 3)
sanjuan_res <- sanjuan_res %>%
mutate(indice_tiempo = as.Date(paste(anio,mes,"01",sep = "-")),
residencia = ifelse(residencia == "no residentes", "No residentes", "Residentes"),
provincia = "San Juan (Ischigualasto)",
Mes = str_to_lower(Mes)) %>%
rename(month = mes)
```
```{r}
# SE LEVANTA LA PIVOT DEL GPI
data_ibera <- read_file_srv("areas_protegidas/areas_protegidas_provinciales/pivot_ibera.xlsx", sheet=2) %>%
mutate(mes_1 = as.numeric(mes_1),
visitantes = as.numeric(visitantes)) %>%
mutate(provincia = "Corrientes",
area_protegida = "Gran Parque Iberá") %>%
mutate(indice_tiempo = as.Date(paste(anio,mes_1,"01",sep = "-"))) %>%
# mes = str_to_sentence(mes))
rename(Mes = mes, month = mes_1)
tabla_parques <- bind_rows(chubut, sanjuan, sanjuan_res, data_ibera) %>%
filter(indice_tiempo <= fecha, anio >= as.integer(.GlobalEnv$anio)-1) %>%
group_by(anio, Mes, month, indice_tiempo, provincia, residencia) %>%
summarise(visitantes = sum(visitantes,na.rm = T)) %>%
ungroup() %>%
arrange(indice_tiempo)
var_ia <- tabla_parques %>%
filter(Mes == Mes) %>%
mutate(residencia = ifelse(is.na(residencia), "Total", tolower(str_replace(residencia, " ", "_")))) %>%
pivot_wider(names_from = "residencia", values_from = "visitantes") %>%
mutate(Total = ifelse(provincia == "Chubut", no_residentes + residentes, Total)) %>%
group_by(provincia) %>%
mutate(var_total = (Total/lag(Total,12))-1,
var_residentes = (residentes/lag(residentes,12))-1,
var_no_residentes = (no_residentes/lag(no_residentes,12))-1,
part_residentes = residentes/Total,
part_no_residentes = no_residentes/Total,
Mes = paste0(Mes," ",anio)) %>%
filter(indice_tiempo == fecha) %>%
select(-c(indice_tiempo, month))
var_acum <- tabla_parques %>%
filter(month <= month(fecha)) %>%
group_by(anio, provincia, residencia) %>%
summarise(visitantes = sum(visitantes, na.rm = T)) %>%
ungroup() %>%
mutate(residencia = ifelse(is.na(residencia), "Total", tolower(str_replace(residencia, " ", "_")))) %>%
pivot_wider(names_from = "residencia", values_from = "visitantes") %>%
mutate(Total = ifelse(provincia == "Chubut", no_residentes + residentes, Total)) %>%
group_by(provincia) %>%
mutate(var_total = (Total/lag(Total,1))-1,
var_residentes = (residentes/lag(residentes,1))-1,
var_no_residentes = (no_residentes/lag(no_residentes,1))-1,
part_residentes = residentes/Total,
part_no_residentes = no_residentes/Total,
Mes = paste0("acumulado ", anio)) %>%
filter(anio == as.integer(.GlobalEnv$anio))
```
En el caso de los parques provinciales, durante el mes de `r mes` se registraron `r lbl_int(var_ia[var_ia$provincia == "Chubut", "Total"] %>% pull())` visitas a áreas naturales protegidas del Chubut, con `r lbl_int(var_ia[var_ia$provincia == "Chubut", "residentes"] %>% pull())` visitas de residentes y `r lbl_int(var_ia[var_ia$provincia == "Chubut", "no_residentes"] %>% pull())` de no residentes. En San Juan, el Parque Provincial Ischigualasto recibió un total de `r lbl_int(var_ia[var_ia$provincia == "San Juan (Ischigualasto)", "Total"] %>% pull())` visitas y el Gran Parque Iberá `r lbl_int(var_ia[var_ia$provincia == "Corrientes (Gran Parque Iberá)", "Total"] %>% pull())`.
```{r}
var_ia %>%
rbind(var_acum) %>%
select(provincia, Mes, Total, var_total, residentes, var_residentes, part_residentes,
no_residentes, var_no_residentes, part_no_residentes) %>%
gt(groupname_col = "provincia") %>%
gt_theme_dnmye() %>%
fmt_number(columns = c(3,5,8), decimals = 0, sep_mark = ".", dec_mark = ",") %>%
fmt_percent(columns = c(4,6,7,9,10), decimals = 1, sep_mark = ".", dec_mark = ",") %>%
cols_label(
Total = md("Visitas") ,
residentes = md("Visitas") ,
no_residentes = md("Visitas") ,
var_no_residentes = md("Var. i.a.<br> %") ,
var_residentes = md("Var i.a.<br> %") ,
var_total = md("Var. i.a.<br> %") ,
part_residentes = md("Part.<br>%"),
part_no_residentes = md("Part.<br>%"),
Mes = md("Período")
) %>%
tab_spanner(
label = md("**TOTAL**"),
columns = vars(Total,
var_total)) %>%
tab_spanner(
label = md("**RESIDENTES**"),
columns = vars(residentes,
var_residentes,
part_residentes)) %>%
tab_spanner(
label = md("**NO RESIDENTES**"),
columns = vars(no_residentes,
var_no_residentes,
part_no_residentes)
) %>%
tab_header(title="Visitas a Áreas Protegidas Provinciales") %>%
cols_align(
align = "center") %>%
fmt_missing(columns = 1:10,
missing_text = "-") %>%
tab_source_note(source_note = "Nota: a partir de enero 2024 se presenta información desagregada por residencia en el Parque Provincial Ishigualasto. A partir de septiembre 2024 se incluye información de visitas en el Área Natural Protegida Cabo Dos Bahías en Chubut y del Gran Parque Iberá en la provincia de Corrientes (incluye información de visitas por 8 portales de acceso al parque). ") %>%
tab_source_note(source_note = "Fuente: DNMyE en base a datos del Parque Provincial Ischigualasto, el Departamento Observatorio Turístico del Chubut y el Departamento Técnico de la Unidad Ejecutora Comité Iberá.")
```
### Recursos - Áreas Protegidas
[**Datos Abiertos**](https://datos.yvera.gob.ar/dataset?groups=turismo-naturaleza)
[**Informes**](https://www.yvera.tur.ar/sinta/informe/info/areas-protegidas)
::: {.infobox}
Para recibir las novedades del SINTA escribíle al bot de Telegram de la DNMyE [*SintIA*](https://bitacora.yvera.tur.ar/posts/2022-09-08-sintia/): @RDatinaBot 🤖
:::