-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
Milestone
Description
DT = data.table(a=1:4, b=c(FALSE, TRUE, NA, FALSE))
DT
# a b
#1: 1 FALSE
#2: 2 TRUE
#3: 3 NA
#4: 4 FALSE
set(DT,3L,1L,0) # ok, no warning
set(DT,3L,2L,0) # should be ok too without warning
# Warning message:
# In set(DT, 3L, 2L, 0) :
# Coerced 'double' RHS to 'logical' to match the column's type; may have truncated precision. Either
# change the target column to 'double' first (by creating a new 'double' vector length 4 (nrows of entire
# table) and assign that; i.e. 'replace' column), or coerce RHS to 'logical' (e.g. 1L, NA_[real|integer]_, as.*,
# etc) to make your intent clear and for speed. Or, set the column type correctly up front when you create
# the table and stick to it, please.
DT
# a b
#1: 1 FALSE
#2: 2 TRUE
#3: 0 FALSE
#4: 4 FALSEApply to 0, 1, 0L and 1L. Just length-1 vectors (i.e. singletons), not longer, as already in place for 0 and 1 to integer.