これを試すことができます。フォルダwww
で 、このファイルを入れて、getIP.js
言う:
$(document).ready(function(){
$.get("http://ipinfo.io", function(response) {
Shiny.onInputChange("getIP", response);
}, "json");
});
ui.R
で:
shinyUI(fluidPage(
tags$head(
tags$script(src="getIP.js")
),
.......
とserver.R
に(観察者が単にテストのためです):
IP <- reactive({ input$getIP })
observe({
cat(capture.output(str(IP()), split=TRUE))
})
その後IP()
の出力(私は私のIPを隠す)のようなリストを得る:
List of 8
$ ip : chr "xx MY IP IS HERE xx"
$ hostname: chr "No Hostname"
$ city : chr "Liège"
$ region : chr "Wallonia"
$ country : chr "BE"
$ loc : chr "50.6412,5.5718"
$ org : chr "AS12392 Brutele SC"
$ postal : chr "4020"
これは完全ではありません。結果はNULL
になることがあります。
こちらをご覧ください:https://shiny.rstudio.com/articles/usage-metrics.htmlこちら:https://shiny.rstudio.com/articles/google-analytics.html – Jav