inner_combine_linter: Require 'c()' to be applied before relatively expensive...

View source: R/inner_combine_linter.R

inner_combine_linterR Documentation

Require c() to be applied before relatively expensive vectorized functions

Description

as.Date(c(a, b)) is logically equivalent to c(as.Date(a), as.Date(b)). The same equivalence holds for several other vectorized functions like as.POSIXct() and math functions like sin(). The former is to be preferred so that the most expensive part of the operation (as.Date()) is applied only once.

Usage

inner_combine_linter()

Tags

consistency, efficiency, readability

See Also

linters for a complete list of linters available in lintr.

Examples

# will produce lints
lint(
  text = "c(log10(x), log10(y), log10(z))",
  linters = inner_combine_linter()
)

# okay
lint(
  text = "log10(c(x, y, z))",
  linters = inner_combine_linter()
)

lint(
  text = "c(log(x, base = 10), log10(x, base = 2))",
  linters = inner_combine_linter()
)


jimhester/lintr documentation built on April 24, 2024, 8:21 a.m.