[R] advice on making HTML tables

Bos, Roger roger.bos at rothschild.com
Tue Jul 14 17:35:42 CEST 2015


This might be a little off topic, but I am starting to produce some HTML reports that contain mostly tables and they look great in Chrome but really bad in IE, so I wanted to see if anyone knows of a better way or an easy fix.  One option I have used is to convert to PDF, but sometimes it is nice to have the report in HTML format.

For my reproducible example, copy the text below into R Studio and hit the knit button. If you look at the HTML output in Chrome the columns are nicely spread out and in IE the columns are jammed right next to each other with minimal/no spacing.  Maybe there is a CSS fix?

---
title: "Untitled"
output: html_document
---

```{r}
knitr::kable(cars)
```

Here is my session info:

R version 3.2.1 Patched (2015-07-11 r68646)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] datasets  tools     utils     stats     graphics  grDevices methods   base

other attached packages:
 [1] xtable_1.7-4        sqldf_0.4-10        RSQLite_1.0.0       DBI_0.3.1           gsubfn_0.6-6
 [6] proto_0.3-10        Rcpp_0.11.6         Quandl_2.6.0        testthat_0.10.0     lubridate_1.3.3
[11] sendmailR_1.2-1     rmarkdown_0.7       devtools_1.8.0      data.table_1.9.4    Rpad_1.3.0
[16] formatR_1.2         dplyr_0.4.2.9002    plyr_1.8.3          reshape2_1.4.1      ggplot2_1.0.1
[21] xts_0.9-7           zoo_1.7-12          XLConnect_0.2-11    XLConnectJars_0.2-9 timeDate_3012.100
[26] R2HTML_2.3.1        RODBC_1.3-12        quadprog_1.5-5      prettyR_2.1-1       MASS_7.3-42
[31] fortunes_1.5-2      corpcor_1.6.8       manipulate_1.0.1

loaded via a namespace (and not attached):
 [1] rJava_0.9-6      lattice_0.20-31  tcltk_3.2.1      colorspace_1.2-6 htmltools_0.2.6
 [6] yaml_2.1.13      base64enc_0.1-2  chron_2.3-47     stringr_1.0.0    munsell_0.4.2
[11] gtable_0.1.2     memoise_0.2.1    evaluate_0.7     knitr_1.10.5     parallel_3.2.1
[16] curl_0.9.1       highr_0.5        scales_0.2.5     rversions_1.0.2  digest_0.6.8
[21] stringi_0.5-5    grid_3.2.1       magrittr_1.5     crayon_1.3.1     xml2_0.1.1
[26] assertthat_0.1   R6_2.1.0         git2r_0.10.1







***************************************************************
This message and any attachments are for the intended recipient's use only.
This message may contain confidential, proprietary or legally privileged
information. No right to confidential or privileged treatment
of this message is waived or lost by an error in transmission.
If you have received this message in error, please immediately
notify the sender by e-mail, delete the message, any attachments and all
copies from your system and destroy any hard copies.  You must
not, directly or indirectly, use, disclose, distribute,
print or copy any part of this message or any attachments if you are not
the intended recipient.



More information about the R-help mailing list