Ironholds / rgeolocate

Generalised IP geolocation through R
https://cran.r-project.org/web/packages/rgeolocate/index.html
Other
66 stars 22 forks source link

compatibility with tidyverse? #51

Closed randomgambit closed 6 years ago

randomgambit commented 6 years ago

I am trying to make rgeolocate work within a mutate call. I found out a way but I wonder if the package could support that natively

library(dplyr)
library(rgeolocate)

mytib <- data_frame(ip = c('17.255.255.255',
                           '17.255.255.255',
                           '17.255.255.255',
                           '17.255.255.255',
                           '17.255.255.255',
                           '17.255.255.255'))

# A tibble: 6 x 1
  ip            
  <chr>         
1 17.255.255.255
2 17.255.255.255
3 17.255.255.255
4 17.255.255.255
5 17.255.255.255
6 17.255.255.255

mytib %>% mutate(aso = maxmind(mytib$ip, 
                               file = '\\GeoLite2-ASN.mmdb',
                               fields = c("aso"))$aso)

# A tibble: 6 x 2
  ip             aso       
  <chr>          <chr>     
1 17.255.255.255 Apple Inc.
2 17.255.255.255 Apple Inc.
3 17.255.255.255 Apple Inc.
4 17.255.255.255 Apple Inc.
5 17.255.255.255 Apple Inc.
6 17.255.255.255 Apple Inc.

it could be the case that doing this actually decreases the performance of the maxmind call... What do you think? Thanks!

Ironholds commented 6 years ago

What do you mean by support it natively?

randomgambit commented 6 years ago

nahh, well I guess this can work as well. I would recommend you put this snipped on your vignette (considering how popular dplyr is)

Thanks

Ironholds commented 6 years ago

I'm still confused about what you were asking for, I guess? Like, that wasn't in opposition, just literally: how else should it work?