R 4.1.0 has added a native pipe operator |> to base R. If you are using the
magrittr pipe %>% and want to switch to |> in your R scripts (you do not
have to), I have a quick function formatR::tidy_pipe() that can help you
substitute %>% with |> in the RStudio editor. All you need to do is open the
R script in RStudio, and run formatR::tidy_pipe() in the R console. Then you
will see %>%’s are converted to |>:
<code …