5
我刚开始使用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()
不错。感谢对象的教训。 –