There may be collisions between variables in .GlobalEnv and variables in the function-call environment, and the parent of the function-call environment probably includes functions & other variables not available in .GlobalEnv. (If the function calls substitute or anything like that then the problem becomes even harder.) I would probably use the debugger to step into the function. If you want more control then create an environment that resembles what would be created in a function call:
env.func <- new.env(parent=environment(f)) delayedAssign(assign.env=env.func, �.) for everything you pass in delayedAssign(assign.env=env.func, eval.env=env.func, �.) for anything that will take a default value eval(envir=env.func, �.) or evalq(envir=env.func, �.) to execute parts of the function body or anything else You can even coerce body(f) to a character, strip the leading �{�, and parse(text=�.) to break the function into expressions. That might be easier than copy-pasting function code. Regards, Jorgen Harmse. Message: 1 Date: Tue, 19 Sep 2023 23:09:18 +0530 From: Brian Smith <briansmith199...@gmail.com> To: r-help@r-project.org Subject: [R] Could you manually replicate execution of a R function Message-ID: <cahubdy_wr_uwtk3t2bu+emvgvkrnhw4ddvmqmq+f0rq6r3o...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Hi, I have trying to replicate a function from rugarch package manually. Below is the calculation based on the function, � [[alternative HTML version deleted]]
______________________________________________ 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.