StatsBase.jl icon indicating copy to clipboard operation
StatsBase.jl copied to clipboard

Make CoefTable width adjustable

Open wildart opened this issue 3 years ago • 2 comments

Large tables tend to mess output by wrapping lines. See https://github.com/JuliaStats/MultivariateStats.jl/issues/186.

This PR make CoefTable width adjustable by omitting columns that are not fit into the screen.

julia> displaysize(stdout)
(40, 85)

julia> ct = CoefTable(rand(3,7), ["c$i" for i in 1:7], [], 4)
───────────────────────────────────────────────────────────────────────
           c1        c2        c3      c4        c5        c6        c7
───────────────────────────────────────────────────────────────────────
[1]  0.509143  0.331133  0.472937  0.2931  0.259103  0.276718  0.546421
[2]  0.333433  0.403466  0.734801  0.0767  0.252618  0.565498  0.513081
[3]  0.630933  0.855958  0.181175  0.1445  0.246145  0.411041  0.377053
───────────────────────────────────────────────────────────────────────

julia> displaysize(stdout) # reduced terminal width
(40, 69)

julia> ct
─────────────────────────────────────────────────────────
           c1        c2        c3      c4        c5   …  
─────────────────────────────────────────────────────────
[1]  0.509143  0.331133  0.472937  0.2931  0.259103   …  
[2]  0.333433  0.403466  0.734801  0.0767  0.252618   …  
[3]  0.630933  0.855958  0.181175  0.1445  0.246145   …  
─────────────────────────────────────────────────────────

julia> displaysize(stdout)  # reduced terminal width
(40, 38)

julia> ct
─────────────────────────────
           c1        c2   …  
─────────────────────────────
[1]  0.509143  0.331133   …  
[2]  0.333433  0.403466   …  
[3]  0.630933  0.855958   …  
─────────────────────────────

julia> show(IOContext(stdout, :limit=>false), ct)
───────────────────────────────────────────────────────────────────────
           c1        c2        c3      c4        c5        c6        c7
───────────────────────────────────────────────────────────────────────
[1]  0.509143  0.331133  0.472937  0.2931  0.259103  0.276718  0.546421
[2]  0.333433  0.403466  0.734801  0.0767  0.252618  0.565498  0.513081
[3]  0.630933  0.855958  0.181175  0.1445  0.246145  0.411041  0.377053
───────────────────────────────────────────────────────────────────────

wildart avatar May 29 '22 05:05 wildart

Would it be possible to print fewer hdots? Matrices and data frames print only one every 5-6 rows.

nalimilan avatar Jun 10 '22 19:06 nalimilan

@nalimilan ready for another review round.

wildart avatar Sep 16 '22 00:09 wildart