0

I am trying to build an app in shiny. I have three sliders and i get the min max values of the sliders in a dataframe using reactive as below:

sliderValues <- reactive({

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

    MaxValue = c(input$weight_1[2],
                   input$weight_2[2],
                   input$weight_3[2]),

    MinValue = c(input$weight_1[1],
                   input$weight_2[1],
                   input$weight_3[1]),

    stringsAsFactors=FALSE

  )})

Now what I have created a function that would take as input this datafram and does some work. My function is the get_uniques as below :

Combs <- reactive({

   get_uniques(prof_test,sliderValues)
  })

  output$values <- renderTable ({
    Combs()
              })

})

The problem is that i get the error "no applicable method for 'xtable' applied to an object of class "character" " , it seems that the reactive dataframe creates an xtable and when i am trying to accesss the values i get this error can you help me ? Thank you!

user3285140
  • 33
  • 1
  • 6
  • Use `sliderValues()` rather then `sliderValues`. Other then that you will need to provide a reproducible example. – jdharrison May 06 '14 at 15:54
  • I have tried that but it did not work i get the following error : "no applicable method for 'xtable' applied to an object of class "reactive" " – user3285140 May 06 '14 at 15:55
  • `renderTable` uses `xtable` internally to produce the html tables. `Combs()` in this case is returning a character rather then a table like structure such as a dataframe or matrix. If your dataframe has a single column you may need to add `, drop = FALSE` to prevent it being coerced down. – jdharrison May 06 '14 at 16:35
  • Where should i use the drop=FALSE ,please? Also i would like to mention that the function get_uniques returns a dataframe with more than one variable. – user3285140 May 06 '14 at 16:42
  • Please provide a reproducible example. See http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – jdharrison May 06 '14 at 16:46
  • I will try to provide one because the data are big and the sample will not work. My base question is that I need the values(min and max) of the sliders to be carried in a dataframe so that i can use them for plots and other stuff. So the basic problem is how i will be able to get the sliderValues build in the Server file as a dataframe. My function at some point has "sliderValues[i,1] " and exactly there i get the error that you explain to me that is because of the xtable. So how i can build the data frame in a manner to have the values from the sliders. Thank you very much for your time. – user3285140 May 06 '14 at 17:44

1 Answers1

1

try to make the return value of Combs as data.frame, i.e.

Combs <- reactive({
   data.frame(get_uniques(prof_test,sliderValues))
  })
pidig89
  • 169
  • 1
  • 11