findUnusedArgs | R Documentation |
These functions analyze an R function and identify parameters or local variables that are not used in the code.
It is useful to remove any dead code with
removeConstIf
and removeAfterReturn
.
This is done by default.
findUnusedArgs(fun, remove = TRUE, clean = TRUE)
findUnusedAssignments(fun, remove = TRUE, clean = TRUE)
fun |
the function to analyze |
clean |
a logical value controlling whether we remove dead code
before processing the function with |
remove |
a logical value controlling whether the code eliminates the dead code and returns the modified code. |
A character vector giving the names of the parameters or local variables that are not used.
Duncan Temple Lang
removeConstIf
, removeAfterReturn
f =
function(a, b, u)
{
z = a + b
ans = g(z)
}
findUnusedArgs(f)
f =
function()
{
a = 1
b = 2
c = 3
d = 10
a + c
}
findUnusedAssignments(f)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.