The grep() family of functions will produce a warning if pattern specified more than one regular expression, e.g.
> pattern <- c("Volvo", "Fiat")
> grep(pattern, rownames(mtcars))
[1] 32
Warning message:
In grep(pattern, rownames(mtcars)) :
argument 'pattern' has length > 1 and only the first element will be used
I don't think that is ever anything other than a coding mistake, i.e. a bug.
Suggestion
Instead of a warning, produce an error:
Error in grep(pattern, rownames(mtcars)) :
argument 'pattern' has length != 1
Issue
The
grep()
family of functions will produce a warning ifpattern
specified more than one regular expression, e.g.I don't think that is ever anything other than a coding mistake, i.e. a bug.
Suggestion
Instead of a warning, produce an error:
This applies to functions:
agrep()
agrepl()
grep()
grepl()
grepRaw()
regexpr()
gregexpr()
regexec()
gsub()
sub()
The above was verified on R 4.0.4.