On 26/02/2008 5:30 AM, Thibaut Jombart wrote: > Jean lobry wrote: >> Dear R-help, >> >> I would like to include the documentation of an R function in an >> *.rnw document processed by Sweave. Because I'm sharing my *.rnw >> files with colleagues under Linux and Windows (I'm on Mac OS X), >> I would like a pure R solution. >> >> The naive approach doesn't work, because Sweaving this *.rnw >> file: >> >> -------- tmp.rnw -------- >> \documentclass{article} >> \begin{document} >> <<>>= >> ?plot >> @ >> \end{document} >> -------- tmp.rnw -------- >> >> yields the following LaTeX file on my platform (session info at the end): >> >> -------- tmp.tex -------- >> \documentclass{article} >> \usepackage{/Library/Frameworks/R.framework/Resources/share/texmf/Sweave} >> \begin{document} >> \begin{Schunk} >> \begin{Sinput} >> >> >>> `?`(plot) >>> >> \end{Sinput} >> \end{Schunk} >> \end{document} >> -------- tmp.tex ------- >> - >> >> in which no Soutput has been generated. Is it possible to redirect the >> help output, in a platform-independent way, so that it is included in >> the Soutput environment of the LaTeX file? >> >> Best, >> >> Jean >> >> >>> sessionInfo() >>> >> R version 2.6.2 (2008-02-08) >> i386-apple-darwin8.10.1 >> >> locale: >> C >> >> attached base packages: >> [1] stats graphics grDevices utils datasets methods base >> >> loaded via a namespace (and not attached): >> [1] rcompgen_0.1-17 >> >> > Maybe a clue: we can use > cat(readLines(as.character(?plot)),sep="\n") > > to display the help (here, of plot) directly to the screen. So we could > use something like: > > <<echo=TRUE,print=FALSE,eval=FALSE>>= > ?plot > @ > > > <<echo=FALSE,print=TRUE,eval=TRUE>>= > cat(readLines(as.character(?plot)),sep="\n") > @ > > But this doesn't work (latex compilation error) as weird characters > appear in the produced tex, at some places (tabulations?), like: > > _T_h_e _D_e_f_a_ > > (not sure what it will look like in this email, but emacs reads things > like _^HT_^HH_^He...). > > Maybe an encoding problem? I tried specifying different encoding to > readLines, with no luck (latin1, UTF-8). Otherwise, the help appears in > the .tex.
Those are backspaces: it's trying to underline the title. You'd get a better display if you read the latex version instead. I think you need to construct the path to it yourself (using system.file() etc.) Duncan Murdoch > Cheers, > > Thibaut. > > > > > sessionInfo() > R version 2.6.2 (2008-02-08) > i686-pc-linux-gnu > > locale: > LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C > > attached base packages: > [1] datasets utils stats graphics grDevices methods base > > other attached packages: > [1] phylobase_0.3 nlme_3.1-87 ape_2.1-1 adegenet_1.1-0 > pixmap_0.4-7 > [6] ade4_1.4-5 MASS_7.2-41 > > loaded via a namespace (and not attached): > [1] grid_2.6.2 lattice_0.17-6 rcompgen_0.1-17 tcltk_2.6.2 > [5] tools_2.6.2 > > ______________________________________________ R-help@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.