I joined two data.tables, dropped the join column and returned the joined datatable. When the function is called, it returns null. If I print the datatable before return, it returns. Tried other operations like str or setorder even then it did not. Why does this happen?
library(data.table)
dmap <- function(){
xx = unlist(strsplit('abcpqr', ''))
div = data.table(division=rep(c('abc', 'pqr'), each=3), state=xx)
stc = data.table(state=xx, stcd = 1:6)
div = div[stc, on='state']
div[, state := NULL]
# print(str(div))
# setorder(div, stcd)
# print(div)
return(div)
}
dmap()
Tried on MacOS 11.5.2 (20G95) R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out" data.table 1.14.1
Red Hat Enterprise Linux release 8.3 (Ootpa) R version 4.0.5 (2021-03-31) -- "Shake and Throw" data.table 1.14.0 using 8 threads