lundi 27 mai 2019

Problem using if and Else to render text in R shiny

I am trying to set up a shiny app which allows individuals to select an option and then with that option a specific text appears if they select the other option different text appears.

Currently i am getting an error, i have tried to use the if else, I am new to shiny and fairly new to R so am struggling with the code.

I have tried playing about with using a reactive x but couldn't get it to work either potentially because this is not numeric?

# Sidebar with a select input for number of bins 
sidebarLayout(
    sidebarPanel(
        selectInput(inputId = "Options",
                    label = "Option",
                    choices = c("Option 1","Option 2"))
    ),

    # Show a text output
    mainPanel(
        textOutput(outputId = "ParticpantInformation1"),
        textOutput(outputId = "ParticpantInformation2")

    )),

# Define server logic required to rendertext
server <- function(input, output) {

    if (input$Options=="Option 1") output$ParticpantInformation1 <- renderText("Option 1")
    else output$ParticpantInformation2 <-renderText("Option 2")

I am hoping for it to render either one set of text or the other onto the main panel of the app

Currently i get an Error - "cannot coerce type 'closure' to vector of type 'character' "

Aucun commentaire:

Enregistrer un commentaire