Skip to content

Commit 22672c1

Browse files
fix key setting order
1 parent 55a6e14 commit 22672c1

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

R/as.data.table.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ as.data.table.data.frame = function(x, keep.rownames=FALSE, key=NULL, ...) {
221221
# kludge it to 'rn' since we only apply the new name afterwards, #4468
222222
if (is.character(keep.rownames) && identical(keep.rownames, key)) key='rn'
223223
ans = data.table(rn=rownames(x), x, keep.rownames=FALSE)
224+
if (!is.null(key)) setkeyv(ans, key)
224225
if (is.character(keep.rownames))
225226
setnames(ans, 'rn', keep.rownames[1L])
226227
return(ans)

0 commit comments

Comments
 (0)