but the record displayed and plotted stays the same no matter how many times I hit next or prev...
I will greatly appreciate any hint that helps me see the error in my ways!
Alternatively, I will also appreciate if someone can help me how to access the "current" record in the DT, that way I will not have to construct my own navigator.
explained in first observer but same logic applies to the rest.
server <- function(input, output) {
RecordPointer <- 1 #created in serverFunction environment, additionally i recommend using 1L as it assigns integer
observeEvent(input$Next, {
RecordPointer <- RecordPointer+1 #RecordPointer created inside observerEvent environment
# value assigned from RecordPointer in serverFunction environment as RecordPointer inside current environment
# doesnt exist yet
# RecordPointer from this environment gets deleted when function call ends
# to change value in serverFunction use:
assign(x = 'RecordPointer',value = RecordPointer+1L , envir = parent.env(environment()))
})
}
To modify a variable in the parent environment, it's easier to just use <<- rather than assign. But in this case I wouldn't even do that; since RecordPointer is just a normal variable it will not trigger reactivity.
These explanations clear the fog I had regarding the scope of the server
function and the event handler functions.
I also appreciate the intro to reactive functions. That explains that when
I tried using <<- to increase the record counter in the event handler it
did not work either.