2014-05-06 27 views
0

我正在試圖構建一個閃亮的應用程序。 我有三個滑塊,我使用反應得到滑塊的最小最大值的數據幀如下:在一個函數中使用反應數據框

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 

)}) 

現在我已經創建,將作爲輸入這個datafram和做一些工作的功能。 我的功能,如下get_uniques:

Combs <- reactive({ 

    get_uniques(prof_test,sliderValues) 
    }) 

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

}) 

的問題是,我得到的錯誤字符「‘’爲‘xtable’適用於類的對象不適用的方法」,似乎反應數據幀創建一個xtable,當我試圖訪問值我得到這個錯誤,你能幫助我嗎? 謝謝!

+0

使用'sliderValues()'而不是'sliderValues'。除此之外,你將需要提供一個可重複的例子。 – jdharrison

+0

我已經嘗試過,但它沒有工作,我得到以下錯誤: 「沒有適用於'xtable'的方法應用於類」對象「反應」 – user3285140

+0

'renderTable'在內部使用'xtable'生成html表。在這種情況下,'Combs()'返回一個字符,而不是像數據框或矩陣這樣的結構。如果你的數據框只有一列,你可能需要添加',drop = FALSE'來防止它被強制關閉。 – jdharrison

回答

1

儘量讓梳子作爲data.frame的返回值,即

Combs <- reactive({ 
    data.frame(get_uniques(prof_test,sliderValues)) 
    }) 
相關問題