gpt4 book ai didi

r - 将 stargazer 或 xable 表插入 knitr 文档中

转载 作者:行者123 更新时间:2023-12-04 10:40:40 25 4
gpt4 key购买 nike

> dput(head(t))
structure(list(Team = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = "Union", class = "factor"),
Date = structure(c(1L, 1L, 1L, 2L, 2L, 2L), .Label = c("2012-01-06",
"2012-02-06", "2012-03-06", "2012-04-06", "2012-05-06", "2012-07-06",
"2012-09-06", "2012-10-06", "2012-11-06", "2012-12-06"), class = "factor"),
STime = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = "07:03", class = "factor"),
ETime = structure(c(6L, 7L, 8L, 5L, 5L, 1L), .Label = c("01:13",
"03:13", "06:13", "09:13", "10:13", "11:13", "12:13", "13:13",
"15:13", "16:13", "18:13"), class = "factor")), .Names = c("Team",
"Date", "STime", "ETime"), row.names = c(NA, 6L), class = "data.frame")

我希望能够使用 stargazer 或 xtable 来放置此数据框 t在 knitr 的表格格式中。我是 knitr 的新手,我可以创建图表等,但无法成功地将表格放入 knitr 文档。

到目前为止,我的 test.rnw 文件如下所示:
\documentclass[11pt]{article}
\begin{document}

<<setup, echo = FALSE, results= 'hide', message = FALSE>>=
data(mtcars)

library(ggplot2)
qplot(speed, dist, data = cars) + geom_smooth()
@

\end{document}

我将如何在此文档中插入观星表以显示 t 的内容数据框?

最佳答案

你的意思是这样的(results='asis')?

\documentclass[11pt]{article}
\begin{document}

<<setup, echo = FALSE, results= 'hide', message = FALSE>>=
data(mtcars)

library(ggplot2)
qplot(speed, dist, data = cars) + geom_smooth()
@


<<results='asis'>>=
require(stargazer)
stargazer(mtcars, summary = FALSE)
@

\end{document}

关于r - 将 stargazer 或 xable 表插入 knitr 文档中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14407576/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com