Skip to content

Commit 8ab87eb

Browse files
fix test; add todo
1 parent c26d268 commit 8ab87eb

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

R/data.table.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2568,6 +2568,7 @@ split.data.table = function(x, f, drop = FALSE, by, sorted = FALSE, keep.by = TR
25682568
if (flatten || length(by) == 1L) {
25692569
for (xi in ll) .Call(C_unlock, xi)
25702570
out = lapply(ll, setDT)
2571+
# TODO(#2000): just let setDT handle this
25712572
if (!identical(old_class <- class(x), c("data.table", "data.frame"))) for (xi in out) setattr(xi, "class", old_class)
25722573
out
25732574
# alloc.col could handle DT in list as done in: c9c4ff80bdd4c600b0c4eff23b207d53677176bd

inst/tests/tests.Rraw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9766,7 +9766,7 @@ test(1639.143, x = split(dt, by = "y"), y = list(`1` = dt))
97669766

97679767
# retain a custom class after splitting, #7105
97689768
DT = data.table(x=letters[1:10], y=1:10, z=rnorm(10))
9769-
setattr(DT, "class", c("my_class", class(dt)))
9769+
setattr(DT, "class", c("my_class", class(DT)))
97709770
test(1639.144, "my_class" %in% unlist(lapply(split(DT, by="x"), class)))
97719771
test(1639.145, "my_class" %in% unlist(lapply(split(DT, ~x), class)))
97729772
test(1639.146, "my_class" %in% unlist(lapply(split(DT, by=c("x", "y")), class)))

0 commit comments

Comments
 (0)