reprex
reprex copied to clipboard
Special considerations around base pipe `|>` and its placeholder `_`
The introduction of the _
placeholder for the base pipe |>
is likely to result in lots of reports of reprex()
not capturing folks reprex or error.
Because invalid use of _
is going to result in a parse error, which is not something reprex can currently capture, because such code cannot be rmarkdown::render()
ed.
@jthomasmock just shared these concrete examples with me.
In the Console, with R 4.2, one sees:
mtcars$disp |> mean
#> Error: The pipe operator requires a function call as RHS
or
mtcars$disp |> mean(_)
#> Error: pipe placeholder can only be used as a named argument
But an attempt to reprex()
the expression mtcars$disp |> mean(_)
results in:
ℹ Rendering reprex...
Error in parse(text = x, keep.source = TRUE) :
pipe placeholder can only be used as a named argument
This is really not a new phenomenon, i.e. we've long had users reporting similar situations where knitr's handling of parsing errors means the code can't be reprex()
ed (e.g. #308, #359, #396). But I suspect increased use of |>
means more people will bump up against this.