-2

I have code written where the following function would change or "mutate" the inputted data.table in R. The following function used to alter the object, dt, but no longer does so. I'm now using data.table version 1.14.8 and R 4.2.1.

test_fn <- function(dt){
  dt[,test := .N]       
}
Mark
  • 7,785
  • 2
  • 14
  • 34
  • 4
    I cannot reproduce the issue. This works fine in data.table 1.14.8: `DT <- data.table(iris); test_fn(DT)` Please provide a minimal reproducible example. – Roland Aug 24 '23 at 06:24
  • 2
    If your function is in a package you are writing, have you added `.datatable.aware <- TRUE` somewhere in the package source? See https://cran.r-project.org/web/packages/data.table/vignettes/datatable-importing.html – r2evans Aug 24 '23 at 12:58

0 Answers0