沒有重複的例子,我真的不能幫你,但是如果我明白你的問題,你只是想保持計數服務器的機制,這樣就可以告訴用戶在什麼位置編號。下面是一個簡單的應用程序,不斷的上下按鈕按下計數:
library(shiny)
# Define UI for application that draws a histogram
ui <- shinyUI(fluidPage(
# Sidebar with a slider input for number of bins
sidebarLayout(sidebarPanel(
actionButton("up","Increase value"),
tags$br(),
actionButton("down","Decrease value")
),
# Show a plot of the generated distribution
mainPanel(
verbatimTextOutput("value")
))
))
# Define server logic required to draw a histogram
server <- shinyServer(function(input, output, session) {
# initiate count at zero
count <- reactiveValues(number=0)
observeEvent(input$up,{
count$number <- count$number + 1
})
observeEvent(input$down,{
count$number <- count$number - 1
})
output$value <- renderPrint({
count$number
})
})
# Run the application
shinyApp(ui = ui, server = server)
謝謝卡爾。這不是我想象的解決問題的方式。我正在考慮讓一個無功元件響應輸入表中當前寫入位置的可能性。我用這個簡單的例子更新了我的問題。 –