Skip to content

Commit

Permalink
Closes #1672, chmatch handles length=0 values in nomatch arg correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
arunsrinivasan committed Apr 25, 2016
1 parent 6537376 commit c8f5dcc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@

53. `fread` won't use `wget` for file:// input, [#1668](https://github.com/Rdatatable/data.table/issues/1668); thanks @MichaelChirico for FR&PR.

54. `chmatch()` handles `nomatch = integer(0)` properly, [#1672](https://github.com/Rdatatable/data.table/issues/1672).

#### NOTES

1. Updated error message on invalid joins to reflect the new `on=` syntax, [#1368](https://github.com/Rdatatable/data.table/issues/1368). Thanks @MichaelChirico.
Expand Down
2 changes: 1 addition & 1 deletion R/data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -2458,7 +2458,7 @@ set <- function(x,i=NULL,j,value) # low overhead, loopable
}

chmatch <- function(x,table,nomatch=NA_integer_)
.Call(Cchmatchwrapper,x,table,as.integer(nomatch),FALSE)
.Call(Cchmatchwrapper,x,table,as.integer(nomatch[1L]),FALSE) # [1L] to fix #1672

"%chin%" <- function(x,table) {
# TO DO if table has 'ul' then match to that
Expand Down
3 changes: 3 additions & 0 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -8809,6 +8809,9 @@ test(1667.1, capture.output(dcast(DT, id ~ rowid(id), value.var = "V1")),
DT <- data.table(a = 1:4, id = 1:4, id = rep(1:4, 2), V1 = 8:1)
test(1667.2, dcast(DT, id ~ rowid(id), value.var = "V1"), error = "data.table to cast")

# fix for #1672
test(1668, chmatch(c("a","b"), c("a","c"), nomatch = integer()), c(1L, NA_integer_))

##########################

# TODO: Tests involving GForce functions needs to be run with optimisation level 1 and 2, so that both functions are tested all the time.
Expand Down

0 comments on commit c8f5dcc

Please sign in to comment.