如何在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>",
)
答案 0 :(得分:0)
代码中的错误主要是 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
)