I have a non-nested list (pretty straight forward). Some elements are NA, but can be replaced by other elements from the same list. I can achieve this with the global assignment operator <<- . However, I am trying to learn the best practice (since this seems to give me notes when compiling the package for CRAN). Questions:
- Can I achieve this without a global mission?
- If not, how can I use
assign appropriately (my approach seems to create a bunch of copies of the same dataset and may occur in memory).
I tried to assign and it does not work. I also tried to use lapply without global assignment, but I can only get the last item, not a list of every item that was replaced.
Here's the problem:
#Fake Data L1 <- lapply(1:3, function(i) rnorm(1)) L1[4:5] <- NA names(L1) <- letters[1:5]
Ultimately, I would like to do this without a global assignment, but if not, then what is best for building a CRAN package.
source share