I am creating a data.table in R and setting a column to be used as key. When I try to retrieve values from the data table; for the rows where there is no match I get NA values back. I typically dont want that behavior in my search. Example below
library(data.table)
dt <- data.table('foo'=seq(10),bar=sample(letters,10))
setkey(dt,bar)
dt[sample(letters,5)]
> dt[sample(letters,5)]
b foo
1: x 4
2: q 2
3: u 8
4: s NA
5: b NA