search for: wrapfun

Displaying 2 results from an estimated 2 matches for "wrapfun".

Did you mean: wrapfun2
2024 Mar 08
1
Function environments serialize to a lot of data until they don't
...payload$data$args$FUN, NULL)) # [1] 1722 And once I've observed `fun`, the environment becomes very small and now can be serialized in a very compact manner. I managed to work around it by forcing the promise and explicitly putting `fun` in a small environment when constructing the closure: .wrapfun <- function(fun) { e <- new.env(parent = loadNamespace('mypackage')) e$fun <- fun # NOTE: a naive return(function(...)) could serialize to 700 # megabytes due to `fun` seemingly being a promise (?). Once the # promise is resolved, suddenly `fun` is much more compact. ret <...
2011 Oct 05
6
reporting multiple objects out of a function
Dear folks, I?m trying to build a function to create and make available some variables I frequently use for testing purposes. Suppose I have a function that takes some inputs and creates (internally) several named objects. Say, fun1 <- function(x, y, z) {obj1 <- x; obj2 <- y; obj3 <- z <missing stuff> } Here is the challenge: After I run it, I want the objects to be