Append a reactive data frame in shiny R

老子叫甜甜 提交于 2019-12-13 10:18:48

问题


I have a code something like this:

for( #loop starts ....
    temp_data_frame <- reactive(d_frame2()[0,]) #only for if i = 1
    temp_data_frame <- reactive(rbind(temp_data_frame(), d_frame2())) 
    )#for loop ends

subset_dataset <-eventReactive(input$go, {temp_data_frame()})
renderDataTable( subset_dataset(), options = list(pageLength = 15))

In d_frame2, I am getting new data each time loop is run. I am creating another temp_data_frame with the same column name as d_frame2, so that appending will be easy. Finally, using renderDataTable I am showing the output. This code results in this error:

evaluation nested too deeply: infinite recursion / options(expressions=)?

I found out that this line: temp_data_frame <- reactive(rbind(temp_data_frame(), d_frame2())) is creating the error. How this can be resolved? Please help.


回答1:


The recursion in your function definition is causing to many (infinite?) evaluations. What if you remove the line all together? Or rename the 2nd function, so

    temp_data_frame2 <- reactive(rbind(temp_data_frame(), d_frame2()))

I just had a similar problem with a recursive function.



来源:https://stackoverflow.com/questions/40887576/append-a-reactive-data-frame-in-shiny-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!