How do you reference values of sliders in shiny?
<p>I need to create some sliders based on number items in a vector:</p>

<p>ui code:</p>

<pre><code>   library(shiny)
library(shinydashboard)
library(leaflet)
library(data.table)
library(ggplot2)
library(ggthemes)
library(usl)

ui&lt;-dashboardPage(skin="green",
                  dashboardHeader(title = "ADM Logical Capacity Planning Service",titleWidth = 350),
                  dashboardSidebar(

                    sidebarMenu(
                      menuItem("Visualize &amp; Create Model", tabName = "visualize",icon=icon("area-chart")),
                      menuItem("Forecast", tabName = "capacity", icon=icon("line-chart"))    )
                  ),
                  dashboardBody(
                    tags$head(tags$style(HTML('
                                              .skin-blue .main-header .logo {
                                              background-color: #3c8dbc;
                                              }
                                              .menuItem .main-header .logo:hover {
                                              background-color: #3c8dbc;
                                              }
                                              '))),


                    tabItems(
                      tabItem("capacity",
                              fluidRow(
                                column(3,
                                       wellPanel(
                                         span("Given the growth rate, forecast the underlying dependent variable")
                                       ),
                                       wellPanel(


                                           # Create a uiOutput to hold the sliders
                                           uiOutput("sliders")
                                        ),



                                         # Generate a row with a sidebar
                                         #sliderInput("capacity", "Growth Rate in Volume:", min=0, max=100, value=0,post="%"),
                                         #br(),
                                         #sliderInput("add_capacity", "Add Capacity in %:", min=0, max=100, value=0,post="%"),


                                       br(),
                                       wellPanel(

                                         actionButton("calcbtn", "Calculate Forecast")
                                       )
                                ),

                                mainPanel(
                                  h4("Prediction"),
                                  verbatimTextOutput("forecast_summary"),

                                  h4("Available Capacity"),
                                  verbatimTextOutput("capacity_summary")

                                  #h4("Peak Capacity"),
                                  #verbatimTextOutput("peak_capacity")
                                )
                              )

                      ),
                      tabItem("visualize",
                              pageWithSidebar(
                                headerPanel("Logical Capacity Planning Dashboard"),
                                sidebarPanel(
                                  fileInput('file1', 'Upload CSV File to Create a Model',
                                            accept=c('text/csv','text/comma-separated-values,text/plain','.csv')),
                                  tags$hr(),
                                  checkboxInput('header', 'Header', TRUE),
                                  fluidRow(
                                    column(6,checkboxGroupInput("xaxisGrp","X-Axis:", c("1"="1","2"="2"))),
                                    column(6,radioButtons("yaxisGrp","Y-axis:", c("1"="1","2"="2")))
                                  ),
                                  radioButtons('sep', 'Separator',
                                               c(Comma=',', Semicolon=';',Tab='\t'), ','),
                                  radioButtons('quote', 'Quote',
                                               c(None='','Double Quote'='"','Single Quote'="'"),'"'),
                                  uiOutput("choose_columns")
                                ),
                                mainPanel(
                                  tabsetPanel(
                                    tabPanel("Data", tableOutput('contents')),
                                    tabPanel("Create Model &amp; Plot",plotOutput("plot"),verbatimTextOutput("PeakCapacity")),
                                    tabPanel("Model Summary",verbatimTextOutput("summary"))

                                  )
                                )
                              )
                      )
                    )
                    )
                    )
</code></pre>

<p>server code:</p>

<pre><code>server &lt;- function(input, output, session) 
{


  ###
  output$sliders &lt;- renderUI({
    xv &lt;- input$xaxisGrp
    # First, create a list of sliders each with a different name
    sliders &lt;- lapply(1:length(xv), function(i) {
      inputName &lt;- xv[i]
      sliderInput(inputName, inputName, min=0, max=100, value=0, post="%")
    })
    # Create a tagList of sliders (this is important)
    do.call(tagList, sliders)
  })



  ###

  observeEvent(input$calcbtn, {

    n &lt;- isolate(input$calcbtn)
    if (n == 0) return()

    output$forecast_summary &lt;- renderPrint({
      n&lt;-pred.model()
      n&lt;-data.frame(n)
      row.names(n)&lt;-NULL
      print(n)
    })

    output$capacity_summary &lt;- renderPrint({
      n&lt;-pred.model()
      n&lt;-data.frame(n)
      row.names(n)&lt;-NULL
      #c&lt;-round(peak.scalability(usl.model()),digits=0)
      available&lt;-round(((c-n[1,1])/c)*100,digits=0)
      row.names(available)&lt;-NULL
      print(paste0(available,"%"))

    })

    #   output$peak_capacity &lt;- renderPrint({

    #    print(paste("Maximum Capacity: ", round(peak.scalability(pred.model()),digits=0)))

    # })

    output$plot_forecast &lt;- renderPlot({
      df &lt;- data_set()
      new_df&lt;- pred.model()

      print(sliders)
      if (!is.null(df)){

        xv &lt;- input$xaxisGrp
        yv &lt;- input$yaxisGrp
        print(xv)
        print(yv)
        if (!is.null(xv) &amp; !is.null(yv)){

          if (sum(xv %in% names(df))&gt;0){ # supress error when changing files

            df1&lt;-data.frame(usl.model()$fitted)
            colnames(df1)&lt;-c("Model")
            df&lt;-cbind(df,df1)
            Model=c("Model")
            #ggplot(df, aes_string(xv,yv))+geom_point(size=3,colour="blue")+geom_line(data=df, aes_string(xv,Model),colour="orange",size=1)+
            #geom_point(data=new_df,aes(new_df[,1],new_df[,2]), colour="red",size=10)+theme_bw()+theme(legend.position = "none")

            #max_capacity&lt;-round(peak.scalability(usl.model()),digits=0)
            Ninety_Fifth_Perc&lt;-quantile(df[,2], 0.95)
            #peak&lt;-round(peak.scalability(usl.model()),digits=0)
            #available&lt;-round(((max_capacity-Ninety_Fifth_Perc)/max_capacity)*100,digits=0)
            new_d&lt;-pred.model()

            ggplot(df, aes_string(xv,yv))+geom_point(size=4,shape=21, fill="blue")+geom_line(data=df, aes_string(xv,Model),colour="orange",size=1)+
              geom_point(data=new_df,aes(new_df[,1],new_df[,2]), colour="red",size=10)+
              theme_bw()+theme(legend.position = "none")+geom_vline(xintercept=new_df[,1], colour="green",size=1.5)



          }
        }
      }

    })

  })

  ###pred function
  pred.model &lt;- reactive({
    xv &lt;- input$xaxisGrp
    yv &lt;- input$yaxisGrp

    #latest_df&lt;-do.call(data.frame,setNames(lapply(xv,function(e) vector(typeof(e))),xv))
    latest_df&lt;-data.frame()
    new_df1 = data.frame()


    for(i in 1:length(xv)){
     ##xv[i]&lt;-as.numeric(input$xv[i])

   # capacity&lt;-as.numeric(input$capacity)
    #add_capacity&lt;-as.numeric(input$add_capacity)

      df &lt;- data_set()
      if (!is.null(df)){

         if (!is.null(xv) &amp; !is.null(yv)){

            if (sum(xv[i] %in% names(df))&gt;0){ # supress error when changing files
          #usl.model &lt;- usl(as.formula(paste(yv, '~', xv)), data = df)

            #new_growth&lt;-tail(df[,xv],1)*(1+capacity/100)
            new_growth&lt;-quantile(df[,xv[i]],0.95)*(1+input$xv[i]/100)
            new_cap&lt;-new_growth

            new_df1[1,i] = setNames(data.frame(new_cap),xv[i])

            row.names(new_df1)&lt;-NULL
            }
         }
      }
    }
    latest_df=new_df1

    prediction&lt;-predict(usl.model(),newdata = latest_df)
    prediction&lt;-data.frame(prediction)
    prediction&lt;-prediction[1,1]

    return(prediction)
})
  ##end of pred function

  ###visualize section
  dsnames &lt;- c()

  data_set &lt;- reactive({
    inFile &lt;- input$file1
    data(specsdm91)
    if (is.null(inFile))
      return(specsdm91)

    data_set&lt;-read.csv(inFile$datapath, header=input$header, 
                       sep=input$sep, quote=input$quote,stringsAsFactors=F)
  })

  output$contents &lt;- renderTable({data_set()})

  observe({
    dsnames &lt;- names(data_set())
    cb_options &lt;- list()
    cb_options[ dsnames] &lt;- dsnames  
    updateCheckboxGroupInput(session, "xaxisGrp",
                       label = "X-Axis",
                       choices = cb_options,
                       selected = "")
    updateRadioButtons(session, "yaxisGrp",
                             label = "Y-Axis",
                             choices = cb_options,
                             selected = "")
  })
  output$choose_dataset &lt;- renderUI({
    selectInput("dataset", "Data set", as.list(data_sets))
  })

  usl.model &lt;- reactive({

    df &lt;- data_set()
    if (!is.null(df)){

      xv &lt;- input$xaxisGrp
      yv &lt;- input$yaxisGrp
      print(xv)
      print(yv)
      if (!is.null(xv) &amp; !is.null(yv)){

        if (sum(xv %in% names(df))&gt;0){ # supress error when changing files
          xv &lt;- paste(xv, collapse="+")

          lim &lt;- lm(as.formula(paste(yv, '~', xv)), data = df)

          return(lim)

        }
      }
    }
  })


  ##plot
  output$plot = renderPlot({

    df &lt;- data_set()
    if (!is.null(df)){

      xv &lt;- input$xaxisGrp
      yv &lt;- input$yaxisGrp
      print(xv)
      print(yv)
      if (!is.null(xv) &amp; !is.null(yv)){

        if (sum(xv %in% names(df))&gt;0){ # supress error when changing files

          #plot(as.formula(paste(yv, '~', xv)), data = df, pch = 21)

          #plot(usl.model(),add=TRUE)

          df1&lt;-data.frame(usl.model()$fitted)
          colnames(df1)&lt;-c("Best_Fit_Model")
          #df&lt;-cbind(df,df1)
          Model&lt;-c("Best_Fit_Model")
          df1&lt;-cbind(df[yv],df1)

          #max_capacity&lt;-round(peak.scalability(usl.model()),digits=0)
          #Ninety_Fifth_Perc&lt;-quantile(df[,2], 0.95)
          #peak&lt;-round(peak.scalability(usl.model()),digits=0)
          #available&lt;-round(((max_capacity-Ninety_Fifth_Perc)/max_capacity)*100,digits=0)
          #new_d&lt;-pred.model()
          df.melt=melt(df, id=yv) 
          xx&lt;-c("value")

          ggplot(df.melt,aes_string(x = xx, y = yv)) + geom_point() +facet_wrap(~variable, scale="free")+theme_bw()+
            geom_smooth(method="lm", se=F, colour="red")

         # p2&lt;-ggplot(df1,aes_string(x = yv, y = Model)) + geom_point() + theme_bw()+
          #  geom_smooth(method="lm", se=F, colour="red")



        }
      }
    }

  } )

  ##
  output$summary &lt;- renderPrint({

    summary(usl.model())

  }) 


  output$choose_columns &lt;- renderUI({

    if(is.null(input$dataset))
      return()
    colnames &lt;- names(contents)
    checkboxGroupInput("columns", "Choose columns", 
                       choices  = colnames,
                       selected = colnames)
  })


}
</code></pre>