案例研究:使用 R 的 Shiny 建置網頁應用程式
Dean Attali
Shiny Consultant



ui <- fluidPage(
textInput(inputId = "name", label = "Enter your name",
value = "Dean"),
numericInput(inputId = "sibs", label = "How many siblings?",
value = 4, min = 0)
)
*Input(inputId, label, ...)inputId = 唯一 IDlabel = 輸入說明文字... = 其他輸入專屬參數兩個步驟:
建立輸出容器(在 UI)
ui <- fluidPage(
"Plot goes here:",
plotOutput(outputId = "my_plot")
)
撰寫 R 程式碼產生輸出(在 server)
server <- function(input, output) {
# Code for building outputs
}
inputoutputui <- fluidPage( numericInput("num", "Number of rows", value = 10, min = 0), tableOutput("my_table") )server <- function(input, output) { output$my_table <- renderTable({ head(iris, n = input$num) }) }
renderPlot()、renderText() 等)output$<outputId>input$<inputId> 取得輸入值案例研究:使用 R 的 Shiny 建置網頁應用程式