Learn R Programming

lintr (version 3.2.0)

rep_len_linter: Require usage of rep_len(x, n) over rep(x, length.out = n)

Description

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()

Arguments

Tags

best_practices, consistency, readability

See Also

linters for a complete list of linters available in lintr.

Examples

Run this code
# will produce lints
lint(
  text = "rep(1:3, length.out = 10)",
  linters = rep_len_linter()
)

# okay
lint(
  text = "rep_len(1:3, 10)",
  linters = rep_len_linter()
)

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

Run the code above in your browser using DataLab