-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImprimir_Reportes.R
80 lines (65 loc) · 2.58 KB
/
Imprimir_Reportes.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
## Script para imprimir reportes
## PBH Jul 2020
# Imprimir reporte individual
rmarkdown::render("Reporte_Viviendas.Rmd",
params = list(viv = "departamento",
barrio="PlazaÑuñoa",
ven="venta"),
output_file = paste("Reportes/Reporte",
"PlazaÑuñoa","departamento",
"26Mar2021", sep="_"))
# Valores que se usarán como "parámetros" (variables) del reporte
barrios <- c("PlazaÑuñoa", "Valdivia")
viviendas <- c("casa", "departamento")
# Alonso
barrios <- c("PlazaÑuñoa","Lastarria","Providencia")
viviendas <- c("departamento")
# Definir función para generación de reportes
for (b in barrios){
for (v in viviendas){
rmarkdown::render("Reporte_Viviendas.Rmd",
params = list(viv = v,
barrio=b,
ven="venta"),
output_file = paste("Reportes/Reporte", b,v,
"26Mar2021", sep="_"))
}
}
# Imprimir reporte Terrenos
rmarkdown::render("Reporte_Terrenos.Rmd",
output_file = paste("Reportes/Reporte", "Aysen", sep="_"))
# Ggplot Aldini
cols_type <- "cccdddDddddddccddDccc"
file_name <- "Data/DataReporte - ValdiviaMar2021.csv"
file_name <- "Data/DataReporte - Alonso Marzo2021.csv"
file_name <- "Data/DataReporte - LaSerenaJulio2021.csv"
df <- read_delim(file_name, delim = ",", skip = 0, na = c("NA"),
col_types = cols_type)
rm(cols_type)
p1 <- df %>%
filter(venta_arriendo=="arriendo",
banos<4, dorm<4) %>%
mutate(tipo_vivienda=factor(tipo_vivienda),
precio_miles=precio/1e3,
Dorms_Banos=paste0(dorm,"D-",banos,"B"),
url=as.character(dir_url),
barrio_nuevo=barrio %>%
str_remove_all("santiago|metropolitana") %>%
str_remove_all("--|---") %>% str_replace("-"," ")) %>%
ggplot(aes(sup,precio_miles,
col=tipo_vivienda,
# col=barrio_nuevo,
label=Dorms_Banos,text=nombre))+
facet_wrap(~barrio_nuevo)+
geom_point(alpha=.5)+
xlab("Superficie Interior [metros cuadrados]")+
ylab("$ Precio en miles CLP ")+
scale_y_continuous(labels=function(x) format(x,big.mark = " ", decimal.mark = ".", scientific = F))+
theme_bw(20)+
ylim(0,1000)+xlim(0,200)
# theme(legend.title = element_blank(), legend.position = "none")
p1
library(plotly)
p <- ggplotly(p1)
htmlwidgets::saveWidget(as_widget(p), "ViviendasLaSerenaArriendo.html")
# EoF