Use the chunk option results=tex, then use cat() in your R code to
output the paragraphs like
<<echo=FALSE, results=tex>>=
for(i in 1:10) {
cat('now the value of i is ', i, '\n\n')
}
@
Regards,
Yihui
--
Yihui Xie <[email protected]>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA
On Fri, Oct 7, 2011 at 10:32 AM, Shane Siers <[email protected]> wrote:
> Dear users and masters--
>
> I am using Sweave with R-2.13.0, MikTeX 2.9, and LyX 2.0.
>
> I would like to be able to use loops in either R or LaTeX to generate
> paragraphs with a standard text format, but values from R data inserted as
> appropriate. The number of paragraphs would change as the number of
> research sites changes. Here is an example of text I had R sink to a .txt
> file with cat statements:
>
> At ASOU1, 20 snakes (7M/13F) were tracked for a total of 138 nights and 109
> successful trials. Snake sizes ranged from 820 to 1130 mm snout-vent length
> (mean=954 ±73), with body condition indexes from 0.82 to 1.45 (mean=1.14
> ±0.15). 90% of transmitters were implanted by voluntary ingestion.
>
> At ASOU2, 30 snakes (13M/11F/6Unk) were tracked for a total of 216 nights
> and 159 successful trials. Snake sizes ranged from 581 to 1117 mm
> snout-vent length (mean=914 ±161), with body condition indexes from 0.93 to
> 1.42 (mean=1.1 ±0.12). 43% of transmitters were implanted by voluntary
> ingestion.
> Is there a way I can recreate this sort of looping behavior in LyX/LaTeX, or
> a way for R to do it and "sink" the results to the desired location in LyX?
> I'd also like to be able to use similar procedures for populating tables.
> --
> Shane
>
>