【发布时间】:2014-01-16 11:07:29
【问题描述】:
我刚开始使用 stargazer 包在 R 中制作回归表,但不知道如何在没有浮动或文档环境的情况下将表输出写入 .tex 文件(以及序言在文档环境的情况下)。也就是说,我只想要表格环境。我的工作流程是将表格浮动环境以及相关的标题和标签保留在论文正文中,并使用\input{}链接到表格的表格环境。
这可能吗?
# bogus data
my.data <- data.frame(y = rnorm(10), x = rnorm(10))
my.lm <- lm(y ~ x, data=my.data)
# if I write to file, then I can omit the floating environment,
# but not the document environment
# (i.e., file contains `\documentclass{article}` etc.)
stargazer(my.lm, float=FALSE, out="option_one.tex")
# if I write to a text connection with `sink`,
# then I can omit both floating and document environments,
# but not commands
# (i.e., log contains `sink` and `stargazer` commands)
con <- file("option_two.tex")
sink(con)
stargazer(my.lm, float=FALSE)
sink()
【问题讨论】: