简体   繁体   English

stargazer type = "html" 表输出中列之间的空格

[英]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.我正在寻找一种方法(或替代方法)来获取 stargazer html-table 输出的列之间的空格。

As作为

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

results in结果是

在此处输入图片说明

which is not very good to read...这不是很好读......

Thank´s in advance!提前致谢!

Samuel塞缪尔

If you are writing an RMarkdown document, you can customize your HTML tables using stylesheets.如果您正在编写 RMarkdown 文档,您可以使用样式表自定义您的 HTML 表格。

This can be done adding the option CSS to your YAML header.这可以通过将选项 CSS 添加到您的 YAML 标头来完成。 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:所以,在你的styles.css文件中,你可以放置如下内容:

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

For further information about using CSS in RMarkdown, please check this .有关在 RMarkdown 中使用 CSS 的更多信息,请查看此 For more about CSS for HTML tables, please check this .有关 HTML 表格的 CSS 的更多信息,请查看此

You can also drop the CSS directly into the RMarkdown document (see here ).您还可以将 CSS 直接放入 RMarkdown 文档中(请参阅此处)。 eg.例如。

---
title: "Untitled"
author: "Author"
date: "29 June 2017"
output: html_document
---

```{css, echo = FALSE}

table, td, th {
  border: none;
  padding-left: 1em;
  padding-right: 1em;
  margin-left: auto;
  margin-right: auto;
  margin-top: 1em;
  margin-bottom: 1em;
}

```


```{r, results = "asis"}

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

```

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM