Skip to content

Commit f1aa244

Browse files
jrwishartchschan
authored andcommitted
DS-4804 Fixup and add unit test
1 parent 8bbd968 commit f1aa244

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
@@ -357,3 +357,17 @@ test_that("Line breaks are properly translated (R -> HTML)", {
357357
test_that("group_by() on a plotly object doesn't produce warning", {
358358
expect_warning(group_by(plot_ly(txhousing), city), NA)
359359
})
360+
361+
test_that("Check QTables dont cause errors", {
362+
.createQTableArray <- function(n, class.name)
363+
structure(
364+
array(runif(n), dim = c(n, 1L)),
365+
class = class.name
366+
)
367+
s <- data.frame(
368+
x = .createQTableArray(10, "QTable"),
369+
y = .createQTableArray(10, "qTable")
370+
)
371+
expect_error(p <- plot_ly(s, x = ~x, y = ~y), NA)
372+
expect_error(print(p), NA)
373+
})

0 commit comments

Comments
 (0)