I inserted the function "myfunc" into the messycode.R script.
The myfunc function is:
myfunc <- function(x){
z <- 2+2
y <- z*2
return(y)
}
After running cleanR on the messycode and then calling myfunc to view it's object contents, I get the following:
function (x)
{
if (ddg.should.run.annotated("myfunc")) {
ddg.function()
ddg.eval("z <- 2 + 2", function ()
parsed.stmt)
ddg.eval("y <- z * 2", function ()
parsed.stmt)
return(ddg.ret.value(ddg.eval("y", function ()
parsed.stmt), function ()
parsed.stmt))
}
else {
z <- 2 + 2
y <- z * 2
return(y)
}
}
I inserted the function "myfunc" into the messycode.R script.
The
myfunc
function is:After running
cleanR
on the messycode and then callingmyfunc
to view it's object contents, I get the following: