0

I was thinking of stop using magrittr library since now we have |> operator. But apparently they are not the same - the new operator produces error. See below

library(magrittr)
library(ggplot2)
library(data.table)

diamonds %>%  setDT  
# runs ok

diamonds |>  setDT
# doesnot run
> Error: The pipe operator requires a function call as RHS

Is that supposed to be that way?

When is it recommended to use %>% vs. |> ?

IVIM
  • 2,167
  • 1
  • 15
  • 41
  • 1
    You would need to use `diamonds |> setDT()`. The native pipe require a function call, not just a function name. – MrFlick Feb 28 '23 at 21:59
  • The error message was very clear to those who understand the terminology used in R. Notice that the SO formatting turned the letters "call" in red, indicating that it was a language term. A naked `setDT` is not a "call". It is a function name. At a minimum an R call will have matching parentheses. Look at the docs: `?is.call` – IRTFM Mar 01 '23 at 01:15

0 Answers0