我在xtable 中看不到将文本添加到表格底部的快速选项(这并不意味着没有),所以我使用了来自here 和链接的想法在你的问题中。这是一个相当粗略的修复,有一个很大的缺点是您需要指定要添加的文本的宽度(等于表格的宽度) - 如果您将其设置得太长,它会拉伸最后一列(查看将 8.5 更改为 10 )。
\documentclass{article}
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}m{#1}}
\begin{document}
\SweaveOpts{concordance=TRUE}
<<yoman,echo=FALSE,results=tex>>=
library(xtable)
mod <- lm(mpg ~ wt, data=mtcars) #my linear model
print(xtable(mod,
caption = "Estimates of linear model for father Muro CB ",
#label = "tab:one",
digits = c(0,2, 2, 2,3)),
table.placement = "h!",
caption.placement = "top",
add.to.row = list(list(2),
"\\hline \\multicolumn{5}{L{8.5cm}}{\\textbf{Note: }
This is a description, blah, blah, blah, blah, blah, blah,
blah, blah, blah, blah, blah, blah, blah, blah, blah, blah,
blah, blah, blah, blah, blah, blah, blah, blah, blah, blah,
blah, blah, blah, blah, blah, blah} \\\\"))
@
\end{document}
我认为 Latex 中有很多替代品可以实现这一点,但可能会让你开始。
来自 cmets: 我尝试将其输出为 html,但没有成功。有什么想法吗?
您可以将 print.table 的 add.to.row 参数中的乳胶命令 multicolumn 更改为使用 html 表函数。 (使用 Rmarkdown 的 html 输出)
```{r,echo=FALSE, results='asis'}
library(xtable)
mod <- lm(mpg ~ wt, data=mtcars) #my linear model
print(xtable(mod,
caption = "Estimates of linear model for father Muro CB ",
digits = c(0,2, 2, 2,3)),
type="html",
caption.placement = "top",
add.to.row = list(list(2),
'<tr><td colspan="5"><b>Note: </b>
This is a description, blah, blah, blah, blah, blah, blah,
blah, blah, blah, blah, blah, blah, blah, blah, blah, blah,
blah, blah, blah, blah, blah, blah, blah, blah, blah, blah,
blah, blah, blah, blah, blah, blah</td></tr>'))
```