Print tibble with column breaks as in v1.3.0

我们两清 提交于 2019-11-26 21:26:52

问题


Using the latest version of tibble the output of wide tibbles is not properly displayed when setting width = Inf.

Based on my tests with previous versions wide tibbles were printed nicely until versions later than 1.3.0. This is what I would like the output to be printed like:

...but this is what it looks like using the latest version of tibble:

I tinkered around with the old sources but to no avail. I would like to incorporate this in a package so the solution should pass R CMD check. When I just copied a load of functions from tibble v1.3.0 I managed to restore the old behavior but could not pass the check.

There's an open issue on Github related to this problem but it's apparently 'not high priority'. Is there a way to print tibbles properly with the new version?


回答1:


Try out this function:

print_width_inf <- function(df, n = 6) {
  df %>%
    head(n = n) %>%
    as.data.frame() %>%
    tibble:::shrink_mat(width = Inf, rows = NA, n = n, star = FALSE) %>%
    `[[`("table") %>%
    print()
}



回答2:


This seems to have change, now one can just use:

options(tibble.width = Inf)


来源:https://stackoverflow.com/questions/44831594/print-tibble-with-column-breaks-as-in-v1-3-0

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!