Domanda

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?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top