Re: [R] R-code in R-file documentation

From: Yihui Xie <xie_at_yihui.name>
Date: Wed, 18 May 2011 13:08:33 -0500

I guess what you want is cat(readLines("file.r"), sep = "\n")

Regards,
Yihui

--
Yihui Xie <xieyihui_at_gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA



On Wed, May 18, 2011 at 4:03 AM, Brian Oney <zenlines_at_gmail.com> wrote:

> Hello List,
> I would like to insert code from .r files into a LaTeX appendix (possibly
> using Sweave).
> I was considering:
>
> <<results=tex,eval=true,echo=true>>=
> source("file.r")
> @
> but I would just like to echo the code and not evaluate the code within the
> file.
> maybe:
> <<results=tex,eval=true,echo=false>>=
> cat("\\begin{verbatim}")
> readLines("file.r")
> cat("\\end{verbatim}")
> @
>
> The above works well other than the line numbers which are included (which
> isn't so bad).
>
> Thanks for the help and ideas!
> Brian
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
______________________________________________ R-help_at_r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Received on Wed 18 May 2011 - 18:11:02 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 18 May 2011 - 18:20:07 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive