Shiny newbie here, struggling with a trivial problem.
Goal: Build a list of names from user input. Each time the user enters a name and clicks Save, append that name to a character vector of names, and update the output with the new contents of that vector.
Problem: Every time they click Save, the character vector has been reinitialized to an empty vector, so the first name is gone, and the new name they entered becomes the only contents of the vector.
Remember What Happens in Vegas Stays in Vegas ad? In R functions can be a lot like that; unless the return value is captured it goes out of scope as soon as the function completes. It's not persistent.
When trying to accumulate a list of return values of function, the trick is to create an object to receive in the global environment, not the local environment. Here's a toy example.
If it’s in a function within a function it’s local to that function. If the inner function returns only to its parent function it stays in that local environment.