【问题标题】:Formatting Tables in Htmltables for R在 R 的 Htmltables 中格式化表格
【发布时间】:2019-05-22 06:56:52
【问题描述】:

如何在 R 中轻松更改 htmltable 中的列宽。我正在使用 htmltable 包。

任何帮助将不胜感激

htmlTable(DataFrame, align = "c",
      rnames = FALSE,
      caption = "<b> <center> <font face = Times New Roman> Table 1.  Population By Territory  <br> <br>",
      tfoot = "<b> Source </b> <br> [1]  Random Data Source",
      header = paste(c(" Territory", "Number of People")),
      css.caption = "color:red;",
      col.rgroup = c("none", "#ADADAD"),
      padding.tspanner = "", ctable = TRUE,
      css.cell = "<td width = 110px>",

)

【问题讨论】:

  • help.search("htmlTable") 返回“未找到结果”。并且...install.packages("htmltable")返回`包'htmltable'不可用(对于R版本3.5.1)`
  • css.cell = "width: 110px",不是css.cell = "&lt;td width = 110px&gt;"

标签: html r html-table css-tables


【解决方案1】:

代码中的错误主要是css.cell 参数,这是html 代码,而不是预期的cascade-style。你可能想做的是:

htmlTable(DataFrame, align = "c",
      rnames = FALSE,
      caption = "<b> <center> <font face = Times New Roman> Table 1.  Population By Territory  <br> <br>",
      tfoot = "<b> Source </b> <br> [1]  Random Data Source",
      header = paste(c(" Territory", "Number of People")),
      css.caption = "color:red;",
      col.rgroup = c("none", "#ADADAD"),
      padding.tspanner = "", ctable = TRUE,
      css.cell = "width: 110px", # <-- drop the "td" stuff, this all goes into the style="" for the element
)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-01-26
    • 1970-01-01
    • 2020-05-02
    • 1970-01-01
    • 1970-01-01
    • 2020-09-09
    • 2019-07-30
    相关资源
    最近更新 更多