mapdist() returns too many lines with duplicated from/to
- Dominant language
- R
- Stars
- 778
- Forks
- 234
- PR merge metrics
- No merged PRs in 30d
Description
When passing a vector of to/from to mapdist that includes repeated pairs of to/from, the returned data frame re-duplicates repeated entries, and returns too many lines.
Here is code that demonstrates the problem.
``` r
library(ggmap)
library(dplyr)
# Create data frame with cities for map test, including repeated lines
cities <-c("Paris, France","London,England","Berlin, Germany")
df <- data_frame(from=rep(cities,2)) %>% mutate(to=lead(from,1)) %>% na.omit()
# Limit to the round trip of cities
roundTrip <- df[1:length(cities),]
# Repeat the first leg
tripRepeatedLeg <- df[1:(length(cities)+1),]
# The starting round trip trip gives the same number of results
roundTripDist <- suppressMessages(mapdist(roundTrip$from,roundTrip$to))
nrow(roundTrip)==nrow(roundTripDist)
# Trips with repeated legs return frames with additional rows
tripRepeatedLegDist <- suppressMessages(mapdist(tripRepeatedLeg$from,tripRepeatedLeg$to))
nrow(tripRepeatedLeg)==nrow(tripRepeatedLegDist)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.