Skip to content

Commit

Permalink
Compute classes before munging list cols.
Browse files Browse the repository at this point in the history
Fixes #1379
  • Loading branch information
hadley committed Sep 8, 2015
1 parent 5489216 commit d53f4e5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# dplyr 0.4.3.9000

* `trunc_mat()` correctly prints the type of list columns (#1379)

# dplyr 0.4.3

## Improved encoding support
Expand Down
2 changes: 1 addition & 1 deletion R/utils-format.r
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ trunc_mat <- function(x, n = NULL, width = NULL) {
rownames(df) <- NULL

# List columns need special treatment because format can't be trusted
classes <- paste0("(", vapply(df, type_sum, character(1)), ")")
is_list <- vapply(df, is.list, logical(1))
df[is_list] <- lapply(df[is_list], function(x) vapply(x, obj_type, character(1)))

mat <- format(df, justify = "left")
values <- c(format(rownames(mat))[[1]], unlist(mat[1, ]))

classes <- paste0("(", vapply(df, type_sum, character(1)), ")")
names <- c("", colnames(mat))

# Column needs to be as wide as widest of name, values, and class
Expand Down

0 comments on commit d53f4e5

Please sign in to comment.