您可以使用Paste 来执行此操作。我确定还有很多其他方法可以做到这一点,请在图库部分的reactivePoll and reactiveFileReader 中查看此示例。下面是一个示例代码,我只需打印出Sys.time() 并将其附加到最后一个条目。
这里有两个例子:
不带按钮的示例 1
library(shiny)
runApp(list(ui = fluidRow(wellPanel(verbatimTextOutput("my_text"))),
server = function(input, output, session) {
autoInvalidate <- reactiveTimer(1000,session)
my_file <- as.character(Sys.time())
output$my_text <- renderText({
autoInvalidate()
my_file <<- paste(my_file,as.character(Sys.time()), sep=",")
})
})
)
带有 ActionButton 的示例 2
library(shiny)
runApp(list(ui = fluidRow(actionButton("push","Append"),wellPanel(verbatimTextOutput("my_text"))),
server = function(input, output, session) {
my_file <- as.character(Sys.time())
output$my_text <- renderText({
if(input$push==0)
{
return(my_file)
}
isolate({
input$push
my_file <<- paste(my_file,as.character(Sys.time()), sep=",")
})
})
})
)