Created
March 1, 2018 12:57
-
-
Save pachevalier/399f50ef036ba88cc2d8325ead6e5a94 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "R Notebook" | |
output: | |
html_document: | |
df_print: paged | |
--- | |
```{r setup} | |
library(banR) | |
library(tidyverse) | |
library(leaflet) | |
``` | |
## Get some toy data | |
```{r toy-data} | |
df <- tribble( | |
~ num_voie, ~ cp, ~ ville, ~ codecommune, | |
"1 Rue Gaspard Monge", "22300", "Lannion", "22113", | |
"Square Edouard Herriot", "85400", "Lucon", "85128") | |
df | |
``` | |
## Geocode with code Insee | |
```{r} | |
df %>% | |
geocode_tbl( | |
adresse = num_voie, | |
code_insee = codecommune | |
) %>% | |
leaflet() %>% | |
addTiles() %>% | |
addMarkers(lng = ~ longitude, lat = ~ latitude) | |
``` | |
## Geocode with postal code | |
```{r} | |
df %>% | |
geocode_tbl( | |
adresse = num_voie, | |
code_postal = cp | |
) %>% | |
leaflet() %>% | |
addTiles() %>% | |
addMarkers(lng = ~ longitude, lat = ~ latitude) | |
``` | |
## Geocode with full adress | |
```{r} | |
df %>% | |
mutate( | |
adr = paste0(num_voie,", ", cp, " ",ville) | |
) %>% | |
geocode_tbl( | |
adresse = adr | |
) %>% | |
leaflet() %>% | |
addTiles() %>% | |
addMarkers(lng = ~ longitude, lat = ~ latitude) | |
``` | |
## Conclusion | |
There is a problem with the postalcode version. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment