dplyr表显示样式更改

时间:2017-10-13 08:41:07

标签: r dplyr tibble

有一段时间dplyr tibbles显示对齐就像data.frame一样,当列的总宽度不方便并排时。

df <- data.frame(a = sample(10^7:11^7, 10), b = sample(10^7:11^7, 10), 
                 c = sample(10^7:11^7, 10), d = sample(10^7:11^7, 10),
                 e = sample(10^7:11^7, 10), f = sample(10^7:11^7, 10), 
                 g = sample(10^7:11^7, 10), h = sample(10^7:11^7, 10),
                 i = sample(10^7:11^7, 10), j = sample(10^7:11^7, 10),
                 k = sample(10^7:11^7, 10)) 
df
#>           a        b        c        d        e        f        g        h
#> 1  17867009 17312938 18210427 10475281 13333318 18956049 10587561 12818614
#> 2  13701262 19114113 17886657 17744679 13047917 13899583 10965135 19317359
#> 3  13764412 14224025 10105385 17199011 12797988 11301752 16639056 17308035
#> 4  11213324 16387578 18464273 11265315 13026476 12026385 15936739 12072416
#> 5  18948002 12647873 17462477 15802797 15654525 18627917 14169203 10038726
#> 6  14625854 10689233 13921686 16902508 17122660 17658381 14064748 11658710
#> 7  10764851 18843579 10596235 11951798 13693438 12405009 14118031 12325924
#> 8  10072186 10253481 12159487 14236954 13946413 16285797 10674194 12546029
#> 9  16490493 13326338 10470197 15193386 10594639 18419217 10507651 18220213
#> 10 10862658 16829857 13924142 10181510 19447742 16876093 10403385 14031469
#>           i        j        k
#> 1  13795825 18844978 15034779
#> 2  15726336 12846753 11844467
#> 3  18109404 17284058 15775025
#> 4  11433114 19466622 12931061
#> 5  13315730 18500464 13190345
#> 6  17340762 16671804 17615337
#> 7  17993227 15329962 14994854
#> 8  10913027 17172156 16803430
#> 9  14214363 15845167 15812424
#> 10 18160982 17118267 14507666

并且tibble.width设置为默认值

df %>% tbl_df()
#> # A tibble: 10 x 11
#>           a        b        c        d        e        f        g        h
#>       <int>    <int>    <int>    <int>    <int>    <int>    <int>    <int>
#>  1 17867009 17312938 18210427 10475281 13333318 18956049 10587561 12818614
#>  2 13701262 19114113 17886657 17744679 13047917 13899583 10965135 19317359
#>  3 13764412 14224025 10105385 17199011 12797988 11301752 16639056 17308035
#>  4 11213324 16387578 18464273 11265315 13026476 12026385 15936739 12072416
#>  5 18948002 12647873 17462477 15802797 15654525 18627917 14169203 10038726
#>  6 14625854 10689233 13921686 16902508 17122660 17658381 14064748 11658710
#>  7 10764851 18843579 10596235 11951798 13693438 12405009 14118031 12325924
#>  8 10072186 10253481 12159487 14236954 13946413 16285797 10674194 12546029
#>  9 16490493 13326338 10470197 15193386 10594639 18419217 10507651 18220213
#> 10 10862658 16829857 13924142 10181510 19447742 16876093 10403385 14031469
#> # ... with 3 more variables: i <int>, j <int>, k <int>

现在时代已经改变了,我在屏幕上看到了这个。

options(tibble.width = Inf)

options(tibble.width = Inf)

df %>% tbl_df()
#> # A tibble: 10 x 11
#>           a        b        c        d        e        f        g        h        i
 j        k
#>     <int>    <int>    <int>    <int>    <int>    <int>    <int>    <int>    <int> 
<int>    <int>
#> 1 17867009 17312938 18210427 10475281 13333318 18956049 10587561 12818614 13795825
18844978 15034779
#> 2 13701262 19114113 17886657 17744679 13047917 13899583 10965135 19317359 15726336
12846753 11844467
#> 3 13764412 14224025 10105385 17199011 12797988 11301752 16639056 17308035 18109404
17284058 15775025
#> 4 11213324 16387578 18464273 11265315 13026476 12026385 15936739 12072416 11433114
19466622 12931061
#> 5 18948002 12647873 17462477 15802797 15654525 18627917 14169203 10038726 13315730
18500464 13190345
#> 6 14625854 10689233 13921686 16902508 17122660 17658381 14064748 11658710 17340762
16671804 17615337
#> 7 10764851 18843579 10596235 11951798 13693438 12405009 14118031 12325924 17993227
15329962 14994854
#> 8 10072186 10253481 12159487 14236954 13946413 16285797 10674194 12546029 10913027
17172156 16803430
#> 9 16490493 13326338 10470197 15193386 10594639 18419217 10507651 18220213 14214363
15845167 15812424
#>10 10862658 16829857 13924142 10181510 19447742 16876093 10403385 14031469 18160982
17118267 14507666

有没有办法像数据帧一样显示“宽度溢出”的情况?我希望有options(dplyr.display_beautiful=TRUE)种解决方案。

0 个答案:

没有答案
相关问题