Skip to content

Commit bdf3874

Browse files
Merge branch 'master' into fix/6605-time-join
2 parents 27711e1 + d782232 commit bdf3874

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

NEWS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ rowwiseDT(
129129

130130
17. Assignment with `:=` to an S4 slot of an under-allocated data.table now works, [#6704](https://github.com/Rdatatable/data.table/issues/6704). Thanks @MichaelChirico for the report and fix.
131131

132-
18. Joining with incompatible column times (e.g., `Date` with `POSIXt`) now provides a clear warning, [#6605](https://github.com/Rdatatable/data.table/issues/6605). Thanks to @al-obrien for the report and @r2evans for the PR.
132+
18. `as.data.table()` method for `data.frame`s (especially those with extended classes) is more consistent with `as.data.frame()` with respect to rention of attributes, [#5699](https://github.com/Rdatatable/data.table/issues/5699). Thanks @jangorecki for the report and fix.
133+
134+
19. Joining with incompatible column times (e.g., `Date` with `POSIXt`) now provides a clear warning, [#6605](https://github.com/Rdatatable/data.table/issues/6605). Thanks to @al-obrien for the report and @r2evans for the PR.
133135

134136
## NOTES
135137

R/as.data.table.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ as.data.table.list = function(x,
214214
}
215215

216216
as.data.table.data.frame = function(x, keep.rownames=FALSE, key=NULL, ...) {
217+
if (!identical(class(x), "data.frame")) return(as.data.table(as.data.frame(x)))
217218
if (!isFALSE(keep.rownames)) {
218219
# can specify col name to keep.rownames, #575; if it's the same as key,
219220
# kludge it to 'rn' since we only apply the new name afterwards, #4468

inst/tests/tests.Rraw

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10578,7 +10578,11 @@ test(1702.1, isoweek(test_cases), test_values)
1057810578
# but calculating from Date brings these into play, #2407
1057910579
test(1702.2, isoweek(as.Date(test_cases)), test_values)
1058010580

10581-
# *** OBSCURE ERROR WHEN Sys.timezone() = 'America/Argentina/Buenos_Aires' ***
10581+
# *** OBSCURE DST ERROR WHEN Sys.timezone() = 'America/Argentina/Buenos_Aires' ***
10582+
# *** 00:00 does not exist, h/t rikivillalba@ who worked through this ***
10583+
# *** https://techcommunity.microsoft.com/blog/dstblog/argentina-is-changing-their-daylight-saving-time-on-december-30/311020 ***
10584+
# *** https://mm.icann.org/pipermail/tz/2007-December/014743.html ***
10585+
# *** Official IANA sources: https://www.iana.org/time-zones ***
1058210586
test(1702.3, isoweek(as.POSIXct(test_cases)), test_values)
1058310587

1058410588
# 1% sample of a 400-year cycle of dates for extra robustness
@@ -20745,3 +20749,14 @@ test(2301.1, DT[order(a, method="auto")], error="no support for sorting by metho
2074520749
test(2301.2, DT[order(a, b, decreasing=c(TRUE, FALSE))], DT[order(-a, b)])
2074620750
test(2301.3, DT[order(a, -b, decreasing=c(TRUE, TRUE))], error="Mixing '-' with vector decreasing")
2074720751
test(2301.4, DT[order(a, b, decreasing=c(TRUE, TRUE, FALSE))], error="decreasing= has length 3")
20752+
20753+
# as.data.table should remove extra attributes from extended data.frames #5699
20754+
x = data.frame(a=c(1,5,3), b=c(2,4,6))
20755+
class(x) = c("tbl", "data.frame")
20756+
attr(x, "t1") = "a"
20757+
as.data.frame.tbl = function(x) {
20758+
attr(x, "t1") = NULL
20759+
class(x) = "data.frame"
20760+
x
20761+
}
20762+
test(2302, attr(as.data.table(y), "t1"), attr(as.data.frame(y), "t1"))

0 commit comments

Comments
 (0)