I want to define a list that a user may update through doing certain actions. I did this:
runApp(list(
ui=fluidPage(
h1('Example')
,textInput('txt','','Text')
,actionButton('add','add')
,verbatimTextOutput('list')
)#ui
,server=function(input,output,session) {
s.list<-reactive(isolate(d.list()))
d.list<-reactive({if (input$add == 0) return()
isolate({
list(input$txt,unlist(s.list()))
})#iso
})#rea
output$list<-renderPrint({
list(unlist(d.list()))
})#list
}#server
))#ruanApp
But the list updates infinitely many times, does anyone know a way to make this work?
You can use reactiveValues
require(shiny)
runApp(list(
ui=fluidPage(
h1('Example')
,textInput('txt','','Text')
,actionButton('add','add')
,verbatimTextOutput('list')
)
,server=function(input,output,session) {
myValues <- reactiveValues()
observe({
if(input$add > 0){
myValues$dList <- c(isolate(myValues$dList), isolate(input$txt))
}
})
output$list<-renderPrint({
myValues$dList
})
}
))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With