View source: R/assignment_style.R
assignment_style | R Documentation |
Check that the left assign symbol (<-
) is used to assign values
to objects instead of the equation assign symbol (=
).
assignment_style(srcData)
srcData |
a list as returned by |
Although =
is a proper assignment symbol at
the top-level, its use is discouraged in R. Good coding practices
dictate to rather use <-
for (left) assignment to objects.
Boolean. When FALSE
, a message indicates the nature of
the error and the faulty lines, and the returned value has the
following attributes:
lines |
faulty line numbers; |
message |
text of the error message. |
## Keep parse data in non interactive sessions.
if (!interactive())
op <- options(keep.source = TRUE)
## Correct coding practice
fil <- tempfile(fileext = ".R")
cat("x <- 2", file = fil, sep = "\n")
assignment_style(getSourceData(fil))
## Incorrect coding practice
cat("x = 2", file = fil, sep = "\n")
assignment_style(getSourceData(fil))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.