2017-05-17 4 views
0

zu diesem Beitrag Basierend: create plots based on radio button selection R ShinyR glänzend Plots basierend auf Radio-Buttons und Slider Eingang

Ich möchte einen anderen Plot Ausgang je nachdem, welche Funkoption der Benutzer auswählt und stellen Sie die Anzahl der Ausschüsse den Slider-Eingang.

Der Schieberegler funktioniert nicht und ich weiß nicht, wie ich das Problem lösen kann. Vielen Dank für die Hilfe!

Hier ist mein Code:

library(shiny) 
library(Cubist)  
plotType <- function(x, type, committe) { 
     switch(type, 
       Cond = dotplot(finalModel, what = "splits"), 
       Coeff = dotplot(finalModel, what = "coefs")) 
    } 
    ui <- shinyUI(fluidPage(
      sidebarLayout(
       sidebarPanel(
       radioButtons(inputId = "ptype", label = "Select the plot", choices = c("Cond", "Coeff")), 
       sliderInput(inputId = "commit", min=1, max = 25, value = 2) 
      ), 
      mainPanel(
       plotOutput("plots")) 
    ))) 

    server <- shinyServer(function(input, output) { 
     output$plots <-renderPlot({ 
      plotType(finalModel, input$ptype, input$commit) 

     }) 
    }) 


    shinyApp(ui = ui, server = server) 

Antwort

-1

Dort am Ende dieser Zeile nicht nötig Komma ist:

sliderInput(inputId = "commit", min=1, max = 25, value = 2), 

sein sollte:

sliderInput(inputId = "commit", min=1, max = 25, value = 2) 
+0

Vielen Dank für Ihren Kommentar. Ich habe das gelöscht. Es hat das Problem leider nicht behoben. Irgendwelche anderen Ideen? Danke – Julia

0

Stellen Sie sicher, hinzufügen lable zu Ihrem sliderinput auch:

library(shiny) 
plotType <- function(x, type, committe) { 
    switch(type,Cond = dotplot(finalModel, what = "splits"),Coeff = dotplot(finalModel, what = "coefs")) 
} 

ui <- shinyUI(fluidPage(
    sidebarLayout(
    sidebarPanel(
     radioButtons(inputId = "ptype", label = "Select the plot", choices = c("Cond", "Coeff")), 
     sliderInput(inputId = "commit","", min=1, max = 25, value = 2) 
    ), 
    mainPanel(
     plotOutput("plots")) 
))) 

server <- shinyServer(function(input, output) { 
    output$plots <- renderPlot({ 
    plotType(finalModel, input$ptype, input$commit) 
    }) 
}) 


shinyApp(ui = ui, server = server) 
+0

Vielen Dank für Ihren Kommentar. Ich habe label hinzugefügt, leider hat es nicht funktioniert. Irgendwelche anderen Ideen? Vielen Dank – Julia

Verwandte Themen