0

I'm using Lyx on Mac and I want to get a regressionn output table with function texreg. My code is:

<<essai, echo=FALSE>>=
library(texreg)
df=data.frame(y=rnorm(100)+2*x, x=1:100)
reg = lm(y~x, data=df)
texreg(reg)
@

But I'didnt get the table in the pdf. I've got lines like this one.

##
## \begin{table}
## \begin{center}

How can I fix it?

RGuay
  • 1
  • 1

1 Answers1

0

You should add the chunk option results='asis':

<<essai, echo=FALSE, results='asis'>>=

The idea is that the R function texreg produces LaTeX, so you want the LaTeX to be interpreted, not escaped.

You can read more about the chunk option here.

scottkosty
  • 2,410
  • 1
  • 16
  • 22
  • Thanks a lot! I've inserted knitr::opts_chunk$set(echo = FALSE,results='asis') and it was going good with function outreg (package rockchalk), but texreg did'nt work and I've received the message LaTeX Error: Not in outer par mode. – RGuay Jul 26 '17 at 20:01
  • Ignore my last comment. I've found the solution. I have to write table=FALSE in the texreg function because I've put the code in a float table. – RGuay Jul 26 '17 at 20:47