Skip to content

Commit

Permalink
Merge pull request #1172 from DavidArenburg/test_branch
Browse files Browse the repository at this point in the history
Edited data.table.R in order to fix setDT ignoring key for data.table…
  • Loading branch information
arunsrinivasan committed Jun 8, 2015
2 parents 7f271b6 + 33f50fc commit 6b89a44
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions R/data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -2459,6 +2459,7 @@ setDT <- function(x, keep.rownames=FALSE, key=NULL) {
if (is.data.table(x)) {
# fix for #1078 and #1128, see .resetclass() for explanation.
setattr(x, 'class', .resetclass(x, 'data.table'))
if (!is.null(key)) setkeyv(x, key) # fix for #1169
if (selfrefok(x) > 0) return(invisible(x)) else alloc.col(x)
} else if (is.data.frame(x)) {
rn = if (!identical(keep.rownames, FALSE)) rownames(x) else NULL
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@
53. Internal function `fastmean()` retains column attributes. Closes [#1160](https://github.com/Rdatatable/data.table/issues/1160). Thanks to @renkun-ken.

54. Using `.N` in `i`, for e.g., `DT[, head(.SD, 3)[1:(.N-1L)]]` accessed incorrect value of `.N`. This is now fixed. Closes [#1145](https://github.com/Rdatatable/data.table/issues/1145). Thanks to @claytonstanley.

55. `setDT` is now setting keys on existing `data.table` object too. Closes [#1169](https://github.com/Rdatatable/data.table/issues/1169). Thanks to @DavidArenburg for the PR.

#### NOTES

Expand Down
6 changes: 6 additions & 0 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -6415,6 +6415,12 @@ x = c(1, 2, 1)
y = c(5, 8, 8, 4)
test(1525, CJ(x, y, unique=TRUE), CJ(c(1,2), c(4,5,8)))

# `key` argument is ignored within `setDT` if `DT` is already a `data.table` #1169
DT <- data.table(A = 1:4, B = 5:8)
setDT(DT, key = "A")
test(1526, key(DT), "A")


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


Expand Down

0 comments on commit 6b89a44

Please sign in to comment.