这是一个非常基本的问题,但任何答案都会有所帮助。
我的问题是,为了能够从 R 导出到 LateX,LaTeX 是否有任何包或安装要求?
我之所以问这个问题,是因为虽然我能够从 R 导出 html 和文本文件,但尝试导出为 LateX 时根本无法输出文件。我只是想制作美观的表格以供发布。
例如
xtable(newobject2, type = "latex", file = "filename2.tex")
不执行任何操作,而
xtable(newobject2, type = "html", file = "filename2.htm")
给我所需的文件输出。
我需要安装 MacTex 才能使用此功能吗?我在 Mac 上
供参考的完整代码如下:
library(foreign)
library(xtable)
library(stargazer)
chap <- read.csv("chap2.csv", header = TRUE)
new <- chap[c("party", "galtan", "sociallifestyle", "civlib_laworder", "religious_principle", "immigrate_policy", "multiculturalism", "urban_rural", "ethnic_minorities", "deregulation", "nationalism", "econ_interven", "redistribution", "spendvtax", "corrupt_salience", "antielite_salience", "international_security", "environment")]
new2 <- new[1:243, 2:18]
fa1 <- factanal(new2, factors = 4, rotation = "varimax", sort = TRUE)
print(fa1, digits = 3, cutoff = .5, sort = TRUE)
newobject2 <- as.data.frame(unclass(fa1$loadings))
xtable(newobject2, type = "latex", file = "filename2.tex")
答案1
欢迎!看看?print.xtable
。这有效
print(xtable(newobject2, type = "latex"), file = "filename2.tex")