library(tidyverse)
library(data.table)
dt <- data.table(x=1:3)
dt[x==1]
myfun <- function(d) d[x==1,x:=NA]
dt2 <- dt %>% myfun
dt[x==1]
In this example dt (a data.table) is being sent as an argument to a function (myfun) via pipe. Then the result is saved into the object dt2.
By why is dt modified? (as you can see the value of x in row 1 goes from 1 to NA)