Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ Suggests:
rmarkdown,
shiny (>= 1.6),
testit,
tibble
tibble,
vctrs
VignetteBuilder:
knitr
Encoding: UTF-8
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# DT (development version)

- `datatable()` now renders data frames with `vctrs::list_of()` list-columns (#1180, @zeehio).

# CHANGES IN DT VERSION 0.34

- DT is now released under the MIT license (previously GPL-3) (#1175).
Expand Down
3 changes: 3 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ captionString = function(caption) {
boxAtomicScalarElements = function(x) {
is_atomic = vapply(x, is.atomic, logical(1))
if (all(is_atomic)) {
if (inherits(x, "vctrs_list_of")) {
x <- as.list(x)
}
is_scalar = lengths(x) == 1L
x[is_scalar] = lapply(x[is_scalar], list)
}
Expand Down
13 changes: 13 additions & 0 deletions tests/testit/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ assert('dropNULL() works', {
(dropNULL(list(a = 1, b = NULL)) %==% list(a = 1))
})

assert('boxAtomicScalarElements() works with vctrs::list_of lists', {
if (requireNamespace("vctrs", quietly = TRUE)) {
val1 <- list("a", c("a", "b"))
out1 <- boxAtomicScalarElements(val1)
val2 <- vctrs::as_list_of(val1)
out2 <- boxAtomicScalarElements(val2)
(out1 %==% out2)
} else {
message("test omitted: vctrs is not installed")
TRUE
}
})

assert('upperToDash() works', {
(upperToDash('fontWeight') %==% 'font-weight')
(upperToDash('backgroundColor') %==% 'background-color')
Expand Down
Loading