This vignette describes transformations to R code that preserve the original semantics but make analysis easier by standardizing the syntax for certain tasks.
return()
StatementsFunctions return the value of their last evaluated expression. An explicit
return()
is only required to exit a function early. Using return()
at the
end of a function is discouraged within the R community because it makes code
less concise.
Identifying return values is necessary for code generation and also for data
flow analyses. We can rewrite code so that all return values have an explicit
return()
. Then it's easy to find return values by class.
When the last expression in a function is a literal, symbol, or call, the
expression can just be wrapped with a return()
. Rewriting is not so
straightforward when the last expression is an assignment or control flow.
Assignments return the value being assigned, but
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.