[datatable-help] Unexpected behavior with mult="all"

Harish harishv_99 at yahoo.com
Sat Jul 31 04:28:49 CEST 2010


I am getting some unexpected behavior with mult="all".

1) Getting a data table when I expect a vector
2) Not getting NA's when I expect them (because of nomatch=NA)

==========

Common code for examples below

x <- data.table(a=c("a","b","d","e"),b=c("A","A","B","B"),d=c(1,2,3,4), key="a,b")
y <- data.table(g=c("a","b","c","d"),h=c("A","A","A","A"))

==========

Issue #1: Getting a data table when I expect a vector

I am not following the logic of when a data.table is returned and when a vector is returned.  Initially, I thought that if j had only one item without a list(), a vector is returned, but I am seeing some contrary behavior.

x[y,d]  # Returns a vector as expected
x[y,d,mult="all"]  # Returns a data.table.  Why?

Would someone help me understand why I should not expect a vector in the last query?

==========
Issue #2: Not getting NA's when I expect them (because of nomatch=NA)

x[y,d,nomatch=NA]  # Expected: returns a vector with NAs in them
x[y,d,nomatch=NA,mult="all]  # Unexpected: NAs not appearing

Am I missing something?

Harish



      


More information about the datatable-help mailing list