-1

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.

Aizen
  • 561
  • 1
  • 9
  • 19

1 Answers1

0

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.

Etienne Moerman
  • 331
  • 1
  • 9
  • Already did that, but if you do so how will the appending work? – Aizen Nov 30 '16 at 12:00
  • Funny thing is that I had to solve my problem using a for-loop. Why do you have the first line in there? – Etienne Moerman Nov 30 '16 at 12:06
  • Is it not possible to replace both lines with this single line? `temp_data_frame <- reactive(rbind(d_frame2()[0,]), d_frame2()))` – Etienne Moerman Nov 30 '16 at 12:08
  • For the first loop it will work, but for the second loop it will simply replace the values in temp_data_frame, so I can't do the appending. – Aizen Nov 30 '16 at 12:13
  • I'm a bit confused about the situation. Does the user enter the data frames manually with the shiny UI? If so, why is the for-loop necessary? As far as I know every time a user makes a change to the front end the reactive statements are executed. So doesn't it run when you replace the entire for-loop with the 2 lines in it? – Etienne Moerman Nov 30 '16 at 12:23