Skip to content

Instantly share code, notes, and snippets.

@jbkunst
Created November 19, 2020 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbkunst/b0b87196ef414b07f25fe0d5e303821a to your computer and use it in GitHub Desktop.
Save jbkunst/b0b87196ef414b07f25fe0d5e303821a to your computer and use it in GitHub Desktop.
# setup -------------------------------------------------------------------
library(readxl)
library(tidyverse)
library(janitor)
library(leaflet)
# recuerden que la expresion hola::chao
# es la funcion 'chao' del paquete 'hola'
# no se pudo encontrar la función "hola"
# seguramente no cargaste el paquete que contiene la funcion hola
# la cola de chancho en windows es mis documentos.
# dir("~/")
# dir("~/../Downloads/")
# readxl::read_excel(path = "~/../Downloads/")
# data --------------------------------------------------------------------
dbip <- readxl::read_excel(path = "pcma20201117oficio-47702013.xlsx", skip = 7)
glimpse(dbip)
dbip %>%
select(`NOMBRE FANTASIA`)
# limpiamos nombres
dbip <- janitor::clean_names(dbip)
glimpse(dbip)
dbip %>%
select(nombre_fantasia)
dbip <- dbip %>%
mutate(
longitud = as.numeric(longitud),
latitud = as.numeric(latitud),
)
dbip <- dbip %>%
mutate(
sab = str_detect(horario_referencial, "Sab|Sáb|sab|sáb")
)
# leaflet -----------------------------------------------------------------
dbip_comuna <- dbip %>%
filter(comuna == 'SANTIAGO', sab)
leaflet(dbip_comuna) %>%
addTiles() %>%
addMarkers(~longitud , ~latitud , popup = ~as.character(nombre_fantasia),
label = ~as.character(nombre_fantasia))
# exportar ----------------------------------------------------------------
saveRDS(dbip, "dbip.rds")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment