質問

Hi i am trying to get several sliders and I want the values of the sliders to be in a matrix. I am trying to get as first step the values to be printed in the page but i get an error of "arguments imply differing number of rows: 2, 0" Please can you help me?

Thank you. The code:

UI.R library(shiny)

attributes <- unique(prof_test[,2])


shinyUI (pageWithSidebar (
        headerPanel("Attribute Model Selection"),
        sidebarPanel(
         lapply(1:2, function(i){


          sliderInput(paste("weight",i,sep="_"), 
                      paste("Select attribute levels :", attributes[i]), 
                      min = 0,
                      max = 1, 
                      value = 1)

          })
            )
     , mainPanel( h3("Analysis"),
                  tableOutput("values")
                  )
     )
 )

SERVER.R library(shiny)

shinyServer( function(input,output){



  sliderValues <- reactive({

data.frame(
  Name = c(as.character(attributes[1]),as.character(attributes[2])),

  MaxValue = c(input$weight1,
               input$weight2),

  stringsAsFactors=FALSE

  )})


            output$values <- renderTable ({

            sliderValues()
          })
})
役に立ちましたか?

解決

I am pulling the answer from the comments into an answer to assist future visitors.

You have sep="_" in paste when declaring ids of sliders. Use input$weight_1

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top