Skip to content

Commit a93fbe9

Browse files
committed
Closes #6592, nested frames break if any are just 1-column
1 parent afa87e1 commit a93fbe9

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ S3method(format_col, POSIXct)
201201
S3method(format_col, expression)
202202
export(format_list_item)
203203
S3method(format_list_item, default)
204+
S3method(format_list_item, data.frame)
204205

205206
export(fdroplevels, setdroplevels)
206207
S3method(droplevels, data.table)

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ rowwiseDT(
115115
116116
15. `DT[1, on=NULL]` now works for returning the first row, [#6579](https://github.com/Rdatatable/data.table/issues/6579). Thanks to @Kodiologist for the report and @tdhock for the PR.
117117
118+
16. Using `print.data.table()` with nested dataframes no longer errors when one of the nested dataframes has only one column, [#6592](https://github.com/Rdatatable/data.table/issues). Thanks to @r2evans for the but report and fix.
119+
118120
## NOTES
119121
120122
1. Tests run again when some Suggests packages are missing, [#6411](https://github.com/Rdatatable/data.table/issues/6411). Thanks @aadler for the note and @MichaelChirico for the fix.

R/print.data.table.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,11 @@ format_list_item.default = function(x, ...) {
237237
}
238238
}
239239

240+
# #6592 -- nested 1-column frames breaks printing
241+
format_list_item.data.frame = function(x, ...) {
242+
paste0("<", class1(x), paste_dims(x), ">")
243+
}
244+
240245
# FR #1091 for pretty printing of character
241246
# TODO: maybe instead of doing "this is...", we could do "this ... test"?
242247
# Current implementation may have issues when dealing with strings that have combinations of full-width and half-width characters,

inst/tests/tests.Rraw

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20596,3 +20596,18 @@ test(2295.3, is.data.table(d2))
2059620596

2059720597
# #6588: .checkTypos used to give arbitrary strings to stopf as the first argument
2059820598
test(2296, d2[x %no such operator% 1], error = '%no such operator%')
20599+
20600+
# #6592: nested single-column frames break in print.data.table
20601+
test(2297.01, format_list_item(data.frame(a=1)), output = "<data.frame\\[1x1]>")
20602+
test(2297.02, format_list_item(data.frame(a=1)[0,,drop=FALSE]), output = "<data.frame\\[0x1]>")
20603+
test(2297.03, format_list_item(data.frame(a=1)[,0]), output = "<data.frame\\[1x0]>")
20604+
test(2297.04, format_list_item(data.frame(a=1, b=2)[0,,drop=FALSE]), output = "<data.frame\\[0x2]>")
20605+
test(2297.05, format_list_item(data.frame(a=1, b=2)[,0]), output = "<data.frame\\[1x0]>")
20606+
test(2297.06, format_list_item(data.table(a=1)), output = "<data.table\\[1x1]>")
20607+
test(2297.07, format_list_item(data.table(a=1)[0,]), output = "<data.table\\[0x1]>")
20608+
test(2297.08, format_list_item(data.table(a=1)[,0]), output = "<data.table\\[0x0]>")
20609+
test(2297.09, format_list_item(data.table(a=1, b=2)[0,]), output = "<data.table\\[0x2]>")
20610+
test(2297.10, format_list_item(data.table(a=1, b=2)[,0]), output = "<data.table\\[0x0]>")
20611+
test(2297.11, data.table(a=1), output = " *a\n1: *1")
20612+
test(2297.12, data.table(a=list(data.frame(b=1))), output = " *a\n1: <data.frame\\[1x1]>")
20613+
test(2297.13, data.table(a=list(data.table(b=1))), output = " *a\n1: <data.table\\[1x1]>")

0 commit comments

Comments
 (0)