tests/env.R

library("R.utils")

x <- list()

x$case1 <- env({
 # Cut'n'pasted from elsewhere
 a <- 1
 b <- 2
})

x$case2 <- env({
 # Cut'n'pasted from elsewhere
 foo <- function(x) x^2
 a <- foo(2)
 b <- 1
 rm(foo) # Not needed anymore
})

# Turn into a list of lists
x <- lapply(x, FUN=as.list)

str(x)

Try the R.utils package in your browser

Any scripts or data that you put into this service are public.

R.utils documentation built on Nov. 18, 2023, 1:09 a.m.