Hello,
Maybe the following is not the recommended way but it works
(and I believe makes sense).
f <- function(){}
formals(f) <- formals(fc)
body(f) <- body(fc)
f
#function (x)
#{
# x <- x + 1
# pi * x
#}
f(1)
#[1] 6.283185
Hope this helps,
Rui Barradas
Às 03:25 de 16-07-2018, Benjamin Tyner escreveu:
Hi
Given a closure which has been compiled, what's the recommended way to
recover the original? For example,
> f <- function(x) x+1
> fc <- cmpfun(f)
> rm(f)
> fc
function(x) x+1
<bytecode: 0x41d9228>
what's the best way to recover f from fc ?
Regards
Ben
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.