dimanche 26 février 2017

Getting randomly latitude/longitude data in R

I simulated a dataset for an online Retail market. The customer can purchase their products in different stores in Germany (e.g. Munich, Berlin, Hamburg..) and in Online stores. To get the latitude/longitude data from the cities I use geocode from the ggmap package. But customers who purchase Online are able to purchase them all over the country. Now I want to generate random latitude/longitude data within Germany for the online purchases, to map them later with shiny leaflet. Is there any way to do this?

My df looks like this:

View(df)
ClientId   Store ... lat   lon
1          Berlin    52    13
2          Munich    48    11
3          Online    x     x  
4          Online    x     x

But my aim is a data frame for example like this:

ClientId   Store ... lat   lon
1          Berlin    52    13
2          Munich    48    11
3          Online    50    12
4          Online    46    10

Is there any way to get these random latitude/longitude data and integrate it to my data frame?




Aucun commentaire:

Enregistrer un commentaire