nutterb / pixiedust

Tables So Beautifully Fine-Tuned You Will Believe It's Magic.
180 stars 18 forks source link

Invalid width and height in LaTeX with dplyr >0.5.0 #82

Closed davidkretch closed 7 years ago

davidkretch commented 7 years ago

When used with dplyr versions >0.5.0, pixiedust functions determine_column_width() and determine_row_height() return width and height of -Inf instead of NA, which are output as invalid LaTeX, e.g. \\parbox[]{-Infpt}.

The change in dplyr is that now, max(x, na.rm = TRUE) returns -Inf if all elements of x are NA, like base R does. This change was in response to issue tidyverse/dplyr#2305, "Hybrid version of max(NAreal, na.rm = TRUE) returns NA".

An example:

library(pixiedust)
fit <- lm(mpg ~ qsec + factor(am) + wt + factor(gear), data = mtcars)
pixiedust:::print_dust_latex(dust(fit))

An excerpt of its output with dplyr 0.6.0. The \\parbox[]{-Infpt} are invalid.

\\setlength{\\tabcolsep}{6pt}\n 
\\begin{table}\n\\centering\n\n\\label{tab:pixie-0}\\begin{tabular}{lrrrr}\n  
\\multicolumn{1}{l}{\\parbox[]{-Infpt}{\\raggedright term}}