Pregunta

I have a code chunk in a .Rnw file like this:

<<test, results = "asis">>=

stargazer(mtcars, notes = c($n$ = \\Sexpr{nrow(mtcars)})

@

When I use knitr to evaluate the R code and convert the .Rnw file to a .tex file, how can I get nrow(mtcars) to evaluate?

¿Fue útil?

Solución

I believe you want something like this:

\documentclass{article}

\begin{document}

<<test, results = "asis">>=
library("stargazer")
stargazer(mtcars, notes = paste('$n$ = ',nrow(mtcars)))
@

\end{document}

You can't put an Sexpr inside a code chunk.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top