# [Tex/LaTex] Export tables from R to LaTeX

r

This is a very basic question but any answers would really help.

My question is are there any package or install requirements for LaTeX in order to be able to export from R to LateX?

I am asking because while I have been able to export html and text files from R, trying to export as LateX doesn't output a file at all. I am simply trying to produce nice looking tables for publication.

E.g

xtable(newobject2, type = "latex", file = "filename2.tex")


Does nothing, whereas

xtable(newobject2, type = "html", file = "filename2.htm")


Gives me the desired file output.

Do I need to install MacTex in order for this to work? I am on a Mac

Full Code for reference is below:

library(foreign)
library(xtable)
library(stargazer)
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)


Welcome! Look at ?print.xtable. This works
print(xtable(newobject2, type = "latex"), file = "filename2.tex")