This is the reproducible example.
if (!require("data.table")) {
install.packages("data.table")
require("data.table")
}
dat <- data.table(a = 1:3)
dat[, b := a + 1]
message("No print above expected, but will occur if you source this script.")
I am suppressing this print by piping it to invisible as follows:
dat[, b := a + 1] |> invisible()
If someone has a better solution, please let us know.