hughjonesd / huxtable

An R package to create styled tables in multiple output formats, with a friendly, modern interface.
http://hughjonesd.github.io/huxtable
Other
321 stars 28 forks source link

devel version set_wrap(TRUE) shrinks column width to longest word #25

Closed zkamvar closed 7 years ago

zkamvar commented 7 years ago

This is as of commit 0a03f49 and was first brought up in #17.

If the user uses set_wrap(TRUE), the column will shrink to the largest word used:

packageVersion("huxtable")
#> [1] '0.3.1.9000'
df <- data.frame(x = 1, y = "this is a very long string with some very long words like function")
hx <- huxtable::as_huxtable(df)
hxw <- huxtable::set_wrap(hx, TRUE)
huxtable::print_md(hxw, max_width = 50)
#> ---------------
#>  1.00 this is  
#>       a very   
#>       long     
#>       string   
#>       with     
#>       some     
#>       very     
#>       long     
#>       words    
#>       like     
#>       function 
#> ---------------
hughjonesd commented 7 years ago

This also happens in print_screen.

The behaviour at the moment is indeed that wrapped cells never expand the width beyond their longest word.

The simplest thing is probably to have a min_width parameter with some reasonable default, say 1/3 * getOption('width'). This will get divided up by the col_width property if this is set, equally otherwise.

hughjonesd commented 7 years ago

Fixed in e268b0a710c3931ec8dae8104fecbc76093a2ea2

zkamvar commented 7 years ago

Thank you so much!