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()
不錯。感謝對象的教訓。 –