Skip to content

Instantly share code, notes, and snippets.

@mgei
Created January 14, 2019 18:00
Show Gist options
  • Save mgei/0269fb9e4120be24af6b5d1d344b89b6 to your computer and use it in GitHub Desktop.
Save mgei/0269fb9e4120be24af6b5d1d344b89b6 to your computer and use it in GitHub Desktop.
fake addresses with realistic locations
library(tidyverse)
library(lubridate)
library(leaflet)
# https://www.fakenamegenerator.com/order.php
# go there to generate fake addresses, don't forget to select to include longitude and latitude
addresses <- read_csv("FakeNameGenerator.com_f201506b.csv")
addresses <- addresses %>% mutate(Birthday = mdy(Birthday),
Title = case_when(Title == "Mr." ~ "Herr",
Title == "Mrs." ~ "Frau",
Title == "Ms." ~ "Frau",
Title == "Dr." & Gender == "female" ~ "Frau Dr.",
Title == "Dr." & Gender == "male" ~ "Herr Dr.",
T ~ Title))
mylat <- 47.5596
mylon <- 7.5886
addresses <- addresses %>%
mutate(distance = sqrt((Longitude-mylon)^2+(Latitude-mylat)^2))
patients <- addresses %>% sample_n(100, weight = 1/distance^2)
patients %>%
leaflet() %>%
setView(lng = mylon, lat = mylat, zoom = 12) %>%
addTiles() %>%
addCircleMarkers(label = ~str_c(GivenName, Surname, StreetAddress, City, sep = " "),
radius = 2, color = "red") %>%
addMarkers(label = "Me", lng = ~mylon, lat = ~mylat)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment