Skip to content

Commit 6ef95b7

Browse files
committed
DS-4804 Fixup and add unit test
1 parent e74b2cf commit 6ef95b7

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

R/plotly.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ plot_ly <- function(data = data.frame(), ..., type = NULL, name,
143143
if (is.data.frame(data) && nrow(data) > 0L) {
144144
qtables <- vapply(data, inherits, logical(1L), c("qTable", "QTable"))
145145
if (any(qtables))
146-
data[qtables] <- lapply(data[qtables], unclass)
146+
data[qtables] <- lapply(data[qtables], as.vector)
147147
}
148148

149149
# "native" plotly arguments

tests/testthat/test-plotly.R

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,3 +358,17 @@ test_that("Line breaks are properly translated (R -> HTML)", {
358358
test_that("group_by() on a plotly object doesn't produce warning", {
359359
expect_warning(group_by(plot_ly(txhousing), city), NA)
360360
})
361+
362+
test_that("Check QTables dont cause errors", {
363+
.createQTableArray <- function(n, class.name)
364+
structure(
365+
array(runif(n), dim = c(n, 1L)),
366+
class = class.name
367+
)
368+
s <- data.frame(
369+
x = .createQTableArray(10, "QTable"),
370+
y = .createQTableArray(10, "qTable")
371+
)
372+
expect_error(p <- plot_ly(s, x = ~x, y = ~y), NA)
373+
expect_error(print(p), NA)
374+
})

0 commit comments

Comments
 (0)