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
Thank you for reporting, are you able to reproduce it on recent version?
On Linux and recent devel I am not having a crash, yet result is corrupted object, that errors when trying to print, so needs some fix anyway.
Worth to note that set is meant to be low overhead function, that can be easily looped million+ times, so probably proper checking for validity of value is not possible.
library(data.table)
n<-1e6dt<-
data.table(
fact=factor(rep("A",n)),
case=rep(TRUE,n),
coeff=rep(5,n))
x<-"fact"
set(
dt,
i= which(dt$case==TRUE),
j="fact",
value=dt[(case),..x]*dt$coeff
)
#Warning message:#In Ops.factor(left, right) : '*' not meaningful for factorsdt#Error in as.character.factor(x) : malformed factor
The root cause, IMHO, is that the logical value NA was assigned to an integer vector (factor vectors are in integer), which should be coerced to the numeric NA_INTEGER first.
A very bad usage of
set
leads to the systematic crash of the Rsession.#
minimal reproductible example
:For the crash to happen :
dt$fact
needs to be afactor
i
needs to be used inset
j
needs to be exactly "fact" (needs to overwrite column "fact")..x
and not "fact" indt[(case),..x]
#
Output of sessionInfo()
The text was updated successfully, but these errors were encountered: