闪亮的 runApp() 无法通过代码或 RStudio 的按钮运行

Mar*_*rio 5 r shiny

我无法运行闪亮的应用程序,无论是通过 RStudio 的“运行应用程序”按钮还是直接使用代码 runApp()

我已经使用这个闪亮的应用程序很多年了。但最近,在没有任何更改的情况下,当我在 RStudio 中按下“运行应用程序”按钮时,应用程序停止工作。然后我输入命令 runApp() 但它也不起作用。

当我按下 RStudio 按钮“运行应用程序”时,我得到:

runApp('')
Error in shinyAppDir(x) : No Shiny application exists at the path ""
Run Code Online (Sandbox Code Playgroud)

shiny::runApp()当我在应用程序开头输入命令时,我得到:

Listening on http://127.0.0.1:3642
Warning: Error in runApp: Can't call `runApp()` from within `runApp()`. If your application code contains `runApp()`, please remove it.
  51: stop
  50: runApp
Error in runApp() : 
  Can't call `runApp()` from within `runApp()`. If your application code contains `runApp()`, please remove it.
Run Code Online (Sandbox Code Playgroud)

工作目录很好。

所以,我被困住了。我无法运行该应用程序。

Mar*_*rio 1

我刚刚意识到当我打开 RStudio 直接打开应用程序时会出现问题;在这种情况下,RStudio 会自动将工作目录识别为应用程序所在的目录。

但是,如果我首先打开 RStudio(例如,从桌面图标)或者工作目录与应用程序所在的目录不同,则不会有任何问题:RStudio 中的“运行应用程序”按钮工作正常。

我认为按钮取决于工作目录,如果工作目录与应用程序目录不同,按钮会自动添加路径,以便应用程序可以运行。但是,如果工作目录与应用程序目录相同,则该按钮会删除该路径,在 runApp() 内留下空白,然后导致问题。