I'm having a problem with recursion in my shiny app. Suppose my app reads a file and creates a dataset (dataset()
). Then I have a function that processes the said dataset, creating another one (dataset.proc()
). I can apply processing to the dataset as many times as I want (there are several processing methods). Another function keeps track of what's the latest dataset created (dataset.current()
).
Here´s a simple example of the important part of my server.R script:
dataset <- reactive(#reads file and creates dataset)
dataset.current <- reactive ({
if (!is.null(dataset())){
if (!is.null(dataset.proc())) {
return(dataset.proc())
} else {
return (dataset())
}
}
})
dataset.proc <- reactive(#processes dataset.current() according to user input, creates a processed dataset)
Is there any way I can 'store' dataset.proc() as a non-reactive expression to avoid the obvious error:
evaluation nested too deeply: infinite recursion
Any help would be much appreciated :)