Skip to content

print and glimpse don't work on a tbl_df that contains data.frame column #775

@jennybc

Description

@jennybc

Since the new data_frame() performs no coercion of its arguments, there will likely be more data.frames (and tbl_dfs) running around with data.frame columns.

Here's a simple one and I've noticed that simple printing and glimpse()ing don't work.

suppressPackageStartupMessages(library(dplyr))

my_vec <- LETTERS[1:3]
my_df <- data.frame(month = month.abb[1:3],
                                        month_name = month.name[1:3])

dplyr_result <- data_frame(my_vec, my_df)
dplyr_result %>% str
dplyr_result
dplyr_result %>% print
dplyr_result %>% glimpse

devtools::session_info() %>%
    capture.output %>%
    grep("dplyr", ., value = TRUE)

And here's what it looks like in my Console:

> suppressPackageStartupMessages(library(dplyr))
> my_vec <- LETTERS[1:3]
> my_df <- data.frame(month = month.abb[1:3],
+ month_name = month.name[1:3])
> dplyr_result <- data_frame(my_vec, my_df)
> dplyr_result %>% str
Classes ‘tbl_df’, ‘tbl’ and 'data.frame':   3 obs. of  2 variables:
 $ my_vec: chr  "A" "B" "C"
 $ my_df :'data.frame': 3 obs. of  2 variables:
  ..$ month     : Factor w/ 3 levels "Feb","Jan","Mar": 2 1 3
  ..$ month_name: Factor w/ 3 levels "February","January",..: 2 1 3
> dplyr_result
Source: local data frame [3 x 2]

Error in `[.data.frame`(X[[2L]], ...) : undefined columns selected
> dplyr_result %>% print
Source: local data frame [3 x 2]

Error in `[.data.frame`(X[[2L]], ...) : undefined columns selected
> dplyr_result %>% glimpse
Variables:
Error in `[.data.frame`(X[[2L]], ...) : undefined columns selected
> devtools::session_info() %>%
+ capture.output %>%
+ grep("dplyr", ., value = TRUE)
Session info---------------------------------------------------------------------------
Packages-------------------------------------------------------------------------------
[1] " dplyr      * 0.3.0.9000 2014-11-06 Github (hadley/dplyr@8b0191a)   "

Metadata

Metadata

Assignees

Labels

bugan unexpected problem or unintended behavior

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions