从快捷方式运行R闪亮应用程序(Windows 10)

时间:2018-02-02 09:38:00

标签: r browser shiny

我想从外行用户的快捷方式开始一个闪亮的应用,与thisthis类似。

我的问题是没有让应用程序启动但是让浏览器打开。单击快捷方式后,我会收到命令提示符并加载脚本并以下列内容结束:收听http://127.0.0.1:xxxx。但是,如果我手动将浏览器导航到localhost:xxxx,则不会打开浏览器,但应用程序就在那里。

第一个剧本:

# packages and working directory
packs <- c("sp","raster","leaflet","shiny","shinydashboard","leaflet.extras","methods")
lapply(packs, require, character.only = TRUE)

setwd("C:/myfolder/test")

# some data to display
BNG <- "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs"

r <- raster(xmn=375000,xmx=380000,ymn=390000,ymx=395000,res=c(50,50),crs=BNG)
r[] <- sample(1:5,size=(50*50),replace = T)

#UI and Server
ui <- bootstrapPage(
  tags$style(type = "text/css", "html, body {width:100%;height:100%}"),
  leafletOutput("rasmap", width = "100%", height = "100%")
)

server <- function(input, output,session) {

  output$rasmap <- renderLeaflet({
    leaflet() %>%
      addProviderTiles("CartoDB.DarkMatter", layerId = "rasmap",
                       options = providerTileOptions(minZoom = 6))%>%
      addRasterImage(r, opacity = 0.8)
  })

}

# tried with and without the below
options(browser = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe")

# I've tried the below in very many permutations
shinyApp(ui, server, options = list(launch.browser=T))
#shinyApp(ui, server)
#runApp(shinyApp(ui, server), launch.browser = TRUE)

在捷径中,我有以下内容:

目标:"C:\Program Files\R\R-3.4.3\bin\R.exe" -e "shiny::runApp('C:/myfolder/test')"

(我在Target的末尾尝试了"shiny::runApp('C:/myfolder/test', launch.browser = TRUE)"但导致它立即崩溃)

开始于:C:/myfolder/test

正如我所说,它工作正常但不会启动浏览器并需要手动输入端口号。运行Windows 10,R 3.4.3,可以从vanilla R和RStudio中正常工作。

0 个答案:

没有答案