Skip to content

Commit

Permalink
Compute classes before munging list cols.
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Sep 8, 2015
1 parent 00265d2 commit a747b5b
Showing 1 changed file with 1 addition and 1 deletion.
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 a747b5b

Please sign in to comment.