Skip to content

Commit 77b4394

Browse files
Merge pull request #6884 from Rdatatable/keeprownames_follow
add test for `as.data.table.data.frame(x, keep.rownames=TRUE)`
2 parents 9fe1b8d + 2c31f1f commit 77b4394

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

NEWS.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
3. `fread(keepLeadingZeros=TRUE)` now correctly parses dates with components with leading zeros as dates instead of strings, [#6851](https://github.com/Rdatatable/data.table/issues/6851). Thanks @TurnaevEvgeny for the report and @ben-schwen for the fix.
1616

17-
4. `as.data.table()` now properly handles keys: specifying keys sets them, omitting keys preserves existing ones, and setting `key=NULL` clears them, [#6859](https://github.com/Rdatatable/data.table/issues/6859). Thanks @brookslogan for the report and @Mukulyadav2004 for the fix.
17+
4. `as.data.table()` now properly handles keys: specifying keys sets them, omitting keys preserves existing ones, and setting `key=NULL` clears them. Additionally, `keep.rownames` is now consistently passed to `as.data.table(x, keep.rownames)`, [#6859](https://github.com/Rdatatable/data.table/issues/6859). Thanks @brookslogan for the report and @Mukulyadav2004 for the fix.
1818

1919
5. `as.data.table()` on `x` avoids an infinite loop if the output of the corresponding `as.data.frame()` method has the same class as the input, [#6874](https://github.com/Rdatatable/data.table/issues/6874). Concretely, we had `class(x) = c('foo', 'data.frame')` and `class(as.data.frame(x)) = c('foo', 'data.frame')`, so `as.data.frame.foo` wound up getting called repeatedly. Thanks @matschmitz for the report and @ben-schwen for the fix.
2020

inst/tests/tests.Rraw

+4
Original file line numberDiff line numberDiff line change
@@ -21105,6 +21105,10 @@ test(2309.06, key(as.data.table(DT, key="a")), "a")
2110521105
test(2309.07, key(as.data.table(DT)), NULL)
2110621106
test(2309.08, key(as.data.table(DT, key=NULL)), NULL)
2110721107

21108+
# as.data.table(x, keep.rownames=TRUE) keeps rownames for class(x)==c("*", "data.frame")
21109+
df = structure(list(i = 1:2), class = c("tbl", "data.frame"), row.names = c("a","b"))
21110+
test(2309.09, as.data.table(df, keep.rownames=TRUE), data.table(rn = c("a","b"), i=1:2))
21111+
2110821112
# as.data.frame(x) does not reset class(x) to "data.frame" #6874
2110921113
as.data.frame.no.reset = function(x) x
2111021114
DF = structure(list(a = 1:2), class = c("data.frame", "no.reset"), row.names = c(NA, -2L))

0 commit comments

Comments
 (0)