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
Currently coerceAs and memrecycle when coercing to factor interprets number as a integer level
coerceAs(0L, as=factor(0L))
#Error in coerceAs(0L, as = factor(0L)) : # Assigning factor numbers to target vector. But 0 is outside the level range [1,1]
Currently what is necessary is to coerce number to character to match base R results
coerceAs("0", as=factor(0L))
#[1] 0#Levels: 0
Question is do we want to make it more consistent to base R.
Then situation like this could just work
dt= data.table(x=1:2, y=factor(1:2))
dt# x y# <int> <fctr>#1: 1 1#2: 2 2dt[1L, c("x","y") :=0L]
##Error in `[.data.table`(dt, 1L, `:=`(c("x", "y"), 0L)) : # Assigning factor numbers to column 2 named 'y'. But 0 is outside the level range [1,2]dt# x y# <int> <fctr>#1: 0 1#2: 2 2
It came up during nafill(dt_of_mixed_types, fill=0L) where fill argument is automatically coerced to a type matching for each column.
Looking forward for comments.
The text was updated successfully, but these errors were encountered:
Currently
coerceAs
andmemrecycle
when coercing to factor interprets number as a integer levelThis is different to how base R coerce works
Currently what is necessary is to coerce number to character to match base R results
Question is do we want to make it more consistent to base R.
Then situation like this could just work
It came up during
nafill(dt_of_mixed_types, fill=0L)
wherefill
argument is automatically coerced to a type matching for each column.Looking forward for comments.
The text was updated successfully, but these errors were encountered: