View source: R/unneeded_concatenation_style.R
unneeded_concatenation_style | R Documentation |
Check that function c
is used with more than one argument.
unneeded_concatenation_style(srcData)
srcData |
a list as returned by |
Function c
is used to combine its arguments. Therefore,
good coding practice dictates that the function should never be used
with zero or one argument.
Usage with zero argument to create an empty vector should be replaced
by calls to object creation functions like numeric
or
character
.
Usage with one argument is a superfluous call to c
that
should just be replaced by the argument.
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 use of the 'c()' function
fil <- tempfile(fileext = ".R")
cat("x <- c(1, 2, 3, 4)", file = fil)
unneeded_concatenation_style(getSourceData(fil))
## Incorrect uses of the 'c()' function
fil <- tempfile(fileext = ".R")
cat("x <- c()",
"x <- c(42)",
file = fil, sep = "\n")
unneeded_concatenation_style(getSourceData(fil))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.