Skip to content

Commit

Permalink
Closes #471. Joins with no 'j', ex: A[A[A]] doesn't result in duplica…
Browse files Browse the repository at this point in the history
…te names anymore, as expected.
  • Loading branch information
arunsrinivasan committed Jul 31, 2014
1 parent bfd2779 commit 347d9f6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ chmatch2 <- function(x, table, nomatch=NA_integer_) {
jisvars = names(i)[-leftcols]
tt = jisvars %chin% names(x)
if (length(tt)) jisvars[tt] = paste("i.",jisvars[tt],sep="")
ansvars = c(names(x), jisvars)
ansvars = make.unique(c(names(x), jisvars))
icols = c(leftcols, seq_along(i)[-leftcols])
icolsAns = c(rightcols, seq.int(ncol(x)+1L, length.out=ncol(i)-length(leftcols)))
xcols = xcolsAns = seq_along(x)[-rightcols]
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ We moved from R-Forge to GitHub on 9 June 2014, including history.
39. `as.data.table.matrix` does not convert strings to factors by default. `data.table` likes and prefers using character vectors to factors. Closes [#745](https://github.com/Rdatatable/data.table/issues/698). Thanks to @fpinter for reporting the issue on the github issue tracker and to vijay for reporting [here](http://stackoverflow.com/questions/17691050/data-table-still-converts-strings-to-factors) on SO.
40. Joins of the form x[y[z]] resulted in duplicate names when all x, y and z had the same column names as non-key columns. This is now fixed. Closes [#471](https://github.com/Rdatatable/data.table/issues/698). Thanks to Christian Sigg for the nice reproducible example.
#### NOTES
1. Reminder: using `rolltolast` still works but since v1.9.2 now issues the following warning:
Expand Down
6 changes: 6 additions & 0 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -4947,6 +4947,12 @@ test(1356, DT1[!DT2], data.table(x=2L, y=4:6, key="x"))
m <- matrix(letters[1:4], ncol=2)
test(1357, as.data.table(m), data.table(V1=letters[1:2], V2=letters[3:4]))

# Fix for #471. A[A[A]] contains duplicate names in 1.9.3
A <- data.table(foo = 1:2, bar = 3:4)
setkey(A, foo)
test(1358.1, names(A[A[A]]), c("foo", "bar", "i.bar", "i.bar.1"))
test(1358.2, names(A[A[A[A]]]), c("foo", "bar", "i.bar", "i.bar.2", "i.bar.1"))

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


Expand Down

0 comments on commit 347d9f6

Please sign in to comment.