i <- reactive({ifelse(inc() <= 26, inc(), -1)})
add <- reactive({
if (input$yes == 0) return(invisible())
isolate({ letters[i()] })
})
alphabet <- reactive({
if (i() < 0) return('No more letters')
else return(letters[i()] )
})
output$testing <- renderPrint({ alphabet() })
output$lastAdd <- renderPrint({ add() })
})
###########
UI.R
library(shiny)
shinyUI(fluidPage(
titlePanel("Iteratively build a list?"),
sidebarLayout(
sidebarPanel(
h3('Is this a vowel?'),
actionButton("yes", label = "Yes"),
actionButton("no", label = "No" )
),
mainPanel(
verbatimTextOutput('lastAdd'),
verbatimTextOutput('testing')
)
)
))
What I want is to have an object that gains a letter every time I click yes. I've been doing some research into reactiveValues but can't
seem to figure out how to append anything to them.
Hope this clarifies my question.