Skip to content
Merged
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
20 changes: 15 additions & 5 deletions R/preparedata.R
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,12 @@ PrepareData <- function(chart.type,
###########################################################################
# Finalizing the result.
###########################################################################


if (chart.type == "Heat" && inherits(data, "QTable"))
{
# Remove QTable class for heatmap to avoid problems with column binding
data.class <- class(data)
class(data) <- setdiff(data.class, "QTable")
}
if (!inherits(data, "QTable") && !is.null(attr(data, "span")))
attr(data, "span") <- NULL
if (tidy.labels)
Expand Down Expand Up @@ -1422,11 +1426,17 @@ transformTable <- function(data,
attr(data, "questions") <- rev(attr(data, "questions"))
if (!is.null(old.span))
attr(data, "span") <- list(rows = old.span$columns, columns = old.span$rows)
} else {
} else if (inherits(data, "QTable"))
{
# Attributes handled by verbs (for QTables)
data <- t(data)
if (!inherits(data, "QTable"))
attr(data, "questions") <- rev(attr(data, "questions"))

} else
{
# Handle attributes ourself
new.data <- t(data)
data <- CopyAttributes(new.data, data)
attr(data, "questions") <- rev(attr(data, "questions"))
}
}

Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-preparedata-tidytable.R
Original file line number Diff line number Diff line change
Expand Up @@ -743,5 +743,8 @@ test_that("Table with Spans", {
"I typically eat and drink whatever I feel like", "Male")), names = c("",
""), row.names = c(1L, 2L, 3L, 5L), class = "data.frame")))

expect_error(res <- PrepareData("Heat", input.data.table = tb2d.with.rowspan), NA)
expect_equal(class(res$data), c("matrix", "array"))

remove(ALLOW.QTABLE.CLASS, envir = .GlobalEnv)
})
Loading