Skip to content

Commit

Permalink
Unnamed column support for 'on=' for character type, #1375.
Browse files Browse the repository at this point in the history
missed this case before...
  • Loading branch information
arunsrinivasan committed Mar 8, 2016
1 parent fa106fa commit 3c9f11c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions R/data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,10 @@ chmatch2 <- function(x, table, nomatch=NA_integer_) {
}
}
if (is.null(i)) return( null.data.table() )
if (is.character(i)) i = data.table(V1=i) # for user convenience; e.g. DT["foo"] without needing DT[.("foo")]
else if (identical(class(i),"list") && length(i)==1L && is.data.frame(i[[1L]])) i = as.data.table(i[[1L]])
if (is.character(i)) {
isnull_inames = TRUE
i = data.table(V1=i) # for user convenience; e.g. DT["foo"] without needing DT[.("foo")]
} else if (identical(class(i),"list") && length(i)==1L && is.data.frame(i[[1L]])) i = as.data.table(i[[1L]])
else if (identical(class(i),"data.frame")) i = as.data.table(i) # TO DO: avoid these as.data.table() and use a flag instead
else if (identical(class(i),"list")) {
isnull_inames = is.null(names(i))
Expand Down
1 change: 1 addition & 0 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -7073,6 +7073,7 @@ X = data.table(A=1:3,b=4:6,c=c("foo","bar","baz"))
Y = data.table(A=2:4, B=5:7)
test(1574.2, X[Y, on=c("A",b="B")], X[Y, on=c(A="A", b="B")])
test(1574.3, X[Y, on=c(b="B", "A")], X[Y, on=c(b="B", A="A")])
test(1574.4, X["bar", on="c"], X[2L]) # missed previously

# fix for #1376
X = data.table(a=1:3,b=4:6,c=c("foo","bar","baz"))
Expand Down

0 comments on commit 3c9f11c

Please sign in to comment.