``` data.table(V1 = factor(as.character(c(NA, 1:100, NA)), exclude = NULL)) # Error in as.character.factor(x) : malformed factor data.table(V1 = factor(as.character(c(NA, 1:3, NA)), exclude = NULL)) # V1 # 1: <NA> # 2: 1 # 3: 2 # 4: 3 # 5: <NA> ``` Is this the expected behaviour? Another example here: https://stackoverflow.com/q/58103098/4552295 I'm getting this result with `data.table_1.12.2` and `R version 3.6.1`.
Activity
jangorecki commentedon Sep 26, 2019
Same in devel. Thanks for reporting. Happens when printing DT having > 100 rows because of head&tail print format.
root cause of the issue is
rbindlistin this linedata.table/R/print.data.table.R
Line 61 in 5ab1884
minimal example
[-]NA as a factor level in a data.table column[/-][+]NA as a factor level malformed by rbindlist[/+]rbindlist malformed NA factor level, #3915