Skip to content

Commit 5ca34a7

Browse files
update key handling
1 parent c4fcff4 commit 5ca34a7

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

R/as.data.table.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,17 @@ as.data.table.data.frame = function(x, keep.rownames=FALSE, key=NULL, ...) {
245245
ans
246246
}
247247

248-
as.data.table.data.table = function(x, keep.rownames = FALSE, key, ...) {
248+
as.data.table.data.table = function(x, keep.rownames = FALSE, ...) {
249249
# as.data.table always returns a copy, automatically takes care of #473
250250
if (any(cols_with_dims(x))) { # for test 2089.2
251-
return(as.data.table.list(x,keep.rownames = keep.rownames, key = key, ...))
251+
return(as.data.table.list(x,keep.rownames = keep.rownames, ...))
252252
}
253253
x = copy(x) # #1681
254254
# fix for #1078 and #1128, see .resetclass() for explanation.
255255
setattr(x, 'class', .resetclass(x, "data.table"))
256-
if (!missing(key)) setkeyv(x, key)
256+
if (methods::hasArg("key")) {
257+
key <- list(...)$key
258+
setkeyv(x, key)
259+
}
257260
x
258261
}

man/as.data.table.Rd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Functions to check if an object is \code{data.table}, or coerce it if possible.
2121
\usage{
2222
as.data.table(x, keep.rownames=FALSE, \dots)
2323

24-
\method{as.data.table}{data.table}(x, \dots)
24+
\method{as.data.table}{data.table}(x, keep.rownames = FALSE, \dots)
2525

2626
\method{as.data.table}{array}(x, keep.rownames=FALSE, key=NULL, sorted=TRUE,
2727
value.name="value", na.rm=TRUE, \dots)

0 commit comments

Comments
 (0)