sammerk sammerk - 4 years ago 305
R Question

Spaces between columns in stargazer type = "html" table output

I`m searching for a method (or alternative) to get spaces between the columns of an stargazer html-table output.

As

stargazer::stargazer(mtcars, type = "html")


results in

enter image description here

which is not very good to read...

ThankĀ“s in advance!

Samuel

Answer Source

If you are writing an RMarkdown document, you can customize your HTML tables using stylesheets.

This can be done adding the option CSS to your YAML header. Something like this:

---
title: "My HTML Doc"
output:
  html_document:
    css: styles.css
---

To increase the spacing between columns you could, for example, add some padding to the left of the cells. So, in your styles.css files you could put something like:

th, td {
    padding-left: 10px;
    text-align: left;        
}

For further information about using CSS in RMarkdown, please check this. For more about CSS for HTML tables, please check this.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download