You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The same way as := makes results invisible I would like to use my function to results invisibly (e.g. writing to database).
Currently my dt[,invisible(.SD)] makes always return visible object, which results below. .SD only represents some transformation:
library(data.table)
dt<- data.table(a=1:2,b=letters[1:2])
f<-function(x) invisible(x)
dt[,f(.SD)] # visible result# nice workaround can be made by:
library(magrittr)
dt[, .SD] %>% invisible# suppress any previous function results visibilitydt[, .SD] %>% f# invisible only because `f`
but the nice workaround require additional dependency in the scripts, maybe there is some trick to make it in data.table?
The text was updated successfully, but these errors were encountered:
# add to `[.data.table``[.data.table`<-function(...){
on.exit({
if(getOption("datatable.inv",FALSE)){
# suppress print the same why as for `:=`
options("datatable.inv"=FALSE)
})
# ...
}
# usagef<-function(x){
options("datatable.inv"=TRUE)
x
}
dt[, f(.SD)]
The same way as
:=
makes results invisible I would like to use my function to results invisibly (e.g. writing to database).Currently my
dt[,invisible(.SD)]
makes always return visible object, which results below..SD
only represents some transformation:but the nice workaround require additional dependency in the scripts, maybe there is some trick to make it in data.table?
The text was updated successfully, but these errors were encountered: