I am attempting to create a function that can update selected values in a global environment variable. To complicate things, these values are located in nested lists, and the depth of the location can vary.
Here is one example:
L <- list()
L$Foo <- list()
L$Foo$Bar <- list()
L$Foo$Bar$VAR <- TRUE
L$Lorem <- list()
L$Lorem$Ipsum <- list()
L$Lorem$Ipsum$Dolor <- list()
L$Lorem$Ipsum$Dolor$VAR <- TRUE
I am trying to update L$Foo$Bar$VAR <- TRUE to L$Foo$Bar$VAR <- FALSE and L$Lorem$Ipsum$Dolor$VAR <- TRUE to L$Lorem$Ipsum$Dolor$VAR <- FALSE. As you see, the variable name inside the nested list, VAR, is the same across all variables I want to update.
Hence, I'm seeking out a function that can update all VAR variables inside a nested list, regardless of how deep VAR is.
EDIT VAR will be updated with the same value.