Skip to contents

rep(x, length.out = n) calls rep_len(x, n) "under the hood". The latter is thus more direct and equally readable.

Usage

rep_len_linter()

See also

linters for a complete list of linters available in lintr.

Examples

# will produce lints
lint(
  text = "rep(1:3, length.out = 10)",
  linters = rep_len_linter()
)
#> <text>:1:1: warning: [rep_len_linter] Use rep_len(x, n) instead of rep(x, length.out = n).
#> rep(1:3, length.out = 10)
#> ^~~~~~~~~~~~~~~~~~~~~~~~~

# okay
lint(
  text = "rep_len(1:3, 10)",
  linters = rep_len_linter()
)
#>  No lints found.

lint(
  text = "rep(1:3, each = 2L, length.out = 10L)",
  linters = rep_len_linter()
)
#>  No lints found.