Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

implicit-assignment

Flag an assignment (<-, =, <<-, ->, ->>) nested inside a call or subscript argument, e.g. mean(x <- 1:10). The binding runs as a side effect of the argument and is easy to miss; assign on its own line instead. The if/while condition case is covered by assignment-in-condition, and the data.table / rlang walrus (:=) is left alone.

This rule is disabled by default; enable it with select.

An assignment hidden inside a call argument:

mean(x <- 1:10)
warning: implicit-assignment
 --> example.R:1:6
  |
1 | mean(x <- 1:10)
  |      ^^^^^^^^^ assignment nested in a call argument; assign on its own line
  = help: Move the assignment to its own statement.