Question

I get a weird result when trying to output my regression results into latex tables using the stargazer package in R: when I simply do

stargazer(linear.1,linear.2)

I get a perfectly fine latex table displayed in the R console that I can then copy and paste into my latex editor. However, when I use

table<-stargazer(linear.1,linear.2)

the character object 'table' does not have the same latex output that one would expect given the results of the first line of code, but rather the same latex code as before with an additional backslash before every backslash in the original latex code, e.g. instead of \begin{document} I get \\begin{document}, instead of two backslashes for a line break I get three backslashes etc.

Any idea what is causing this behavior and how I could fix it?

Thanks!

Was it helpful?

Solution

Perfectly normal behavior, as backslashes in R string require an escape character that just happens to be... a baskslash!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top