啟動一個閃亮的應用程式
你可以通過多種方式啟動應用程式,具體取決於你建立應用程式的方式。如果你的應用分為兩個檔案 ui.R 和 server.R,或者你的所有應用都在一個檔案中。
1.兩個檔案的應用程式
你的兩個檔案 ui.R 和 server.R 將在同一個資料夾中。然後,你可以通過在控制檯中執行 shinyApp() 函式並傳遞包含 Shiny 應用程式的目錄的路徑來啟動你的應用程式。
shinyApp("path_to_the_folder_containing_the_files")
你還可以在開啟 ui.R 或 server.R 檔案時按 Rstudio 上顯示的 執行應用程式 按鈕,直接從 Rstudio 啟動應用程式。

或者,如果你的工作目錄是 Shiny App 目錄,你只需在控制檯上編寫 runApp() 即可。
2.一個檔案應用程式
如果你在一個 R 檔案中建立,你也可以使用 shinyApp() 函式啟動它。
- 你的程式碼裡面:
library(shiny)
ui <- fluidPage() #Create the ui
server <- function(input, output){} #create the server
shinyApp(ui = ui, server = server) #run the App
- 在控制檯中新增路徑到
.R檔案包含 Shiny 應用程式與引數appFile:
shinyApp(appFile="path_to_my_R_file_containig_the_app")