You can install the R ipify
package using devtools:
library(devtools)
install_github("gregce/ipify")
library(ipify)
get_ip()
## No encoding supplied: defaulting to UTF-8.
## [1] "73.162.222.85"
get_ip(format="json")
## $ip
## [1] "73.162.222.85"
get_ip(format="jsonp")
## No encoding supplied: defaulting to UTF-8.
## [1] "callback({\"ip\":\"73.162.222.85\"});"