Skip to content

Commit

Permalink
as_data_frame.tbl_cube() now uses stringsAsFactors = FALSE
Browse files Browse the repository at this point in the history
in accordance with the tibble philosophy
  • Loading branch information
Kirill Müller committed Feb 19, 2016
1 parent 1bef3d0 commit 467924b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion R/dataframe.R
Expand Up @@ -196,7 +196,7 @@ as_data_frame.matrix <- function(x, ...) {
#' @export
#' @rdname as_data_frame
as_data_frame.tbl_cube <- function(x, ...) {
as_data_frame(as.data.frame(x, ...))
as_data_frame(as.data.frame(x, ..., stringsAsFactors = FALSE))
}

#' Convert row names to an explicit variable.
Expand Down
2 changes: 1 addition & 1 deletion R/tbl-cube.r
Expand Up @@ -144,7 +144,7 @@ print.tbl_cube <- function(x, ...) {

#' @export
as.data.frame.tbl_cube <- function(x, ...) {
dims <- expand.grid(x$dims, KEEP.OUT.ATTRS = FALSE)
dims <- expand.grid(x$dims, KEEP.OUT.ATTRS = FALSE, ...)
mets <- lapply(x$mets, as.vector)

all <- c(dims, mets)
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/test-tbl-cube.R
Expand Up @@ -13,5 +13,6 @@ test_that("summarise works with single group", {
test_that("can coerce to data_frame", {
slice <- filter(nasa, year == 1995L, month == 1L)

expect_identical(tbl_df(as.data.frame(slice)), as_data_frame(slice))
expect_identical(tbl_df(as.data.frame(slice, stringsAsFactors = FALSE)),
as_data_frame(slice))
})

0 comments on commit 467924b

Please sign in to comment.