[R] One pdf file with plots and text output

Romain Francois rfrancois at mango-solutions.com
Wed Oct 17 14:47:26 CEST 2007


You can also specify the full path of the latex package, for me:

\usepackage{/usr/local/lib/R/share/texmf/Sweave}

Regards,

Romain

ONKELINX, Thierry wrote:
> It works fine with me (on windows). But I've copied sweave.sty into my
> workdirectory. See the Sweave FAQ
> (http://www.ci.tuwien.ac.at/~leisch/Sweave/FAQ.html#x1-14000A.12)
>
>
> ------------------------------------------------------------------------
> ----
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature
> and Forest
> Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
> methodology and quality assurance
> Gaverstraat 4
> 9500 Geraardsbergen
> Belgium
> tel. + 32 54/436 185
> Thierry.Onkelinx at inbo.be
> www.inbo.be 
>
> Do not put your faith in what statistics say until you have carefully
> considered what they do not say.  ~William W. Watt
> A statistical analysis, properly conducted, is a delicate dissection of
> uncertainties, a surgery of suppositions. ~M.J.Moroney
>
>
>
>   
>> -----Oorspronkelijk bericht-----
>> Van: Rainer M Krug [mailto:Rainer+R-help at krugs.de] 
>> Verzonden: woensdag 17 oktober 2007 14:17
>> Aan: ONKELINX, Thierry
>> CC: r-help
>> Onderwerp: Re: [R] One pdf file with plots and text output
>>
>> I am getting somewhere - but running system("pdflatex 
>> GrowthAll") fails, as it does not find sweave.sty. I already 
>> linked the directory where it can be found 
>> (/usr/lib/R/share/texmf/) into my personal texfm directory 
>> (/texmf/tex/latex/R)\ and ran texhash (as root and as n ormal 
>> user), but it still does not find it. If I enter the filename 
>> manually, pdflatex works.
>>
>> Any ideas?
>>
>> Rainer
>>
>>
>> ONKELINX, Thierry wrote:
>>     
>>> You create a source file ("GrowthAll.Rnw") that looks a bit 
>>>       
>> like this
>>     
>>> \documentclass[11pt]{report}
>>> \usepackage{Sweave}
>>> \SweaveOpts{echo = FALSE}
>>> \begin{document}
>>>
>>> <<fig = T>>=
>>> x.lm <- lm()
>>> plot(x.lm)
>>> @
>>>
>>> <<>>=
>>> summary(x.lm)
>>> @
>>> \end{document}
>>>
>>>
>>> Then run in R: 
>>> Sweave("GrowthAll.Rnw")
>>> system("pdflatex GrowthAll")
>>>
>>> Have a look at the Sweave manual. It contains some examples.
>>>
>>> HTH,
>>>
>>> Thierry
>>>
>>>
>>>       
>> ----------------------------------------------------------------------
>>     
>>> --
>>> ----
>>> ir. Thierry Onkelinx
>>> Instituut voor natuur- en bosonderzoek / Research Institute 
>>>       
>> for Nature 
>>     
>>> and Forest Cel biometrie, methodologie en kwaliteitszorg / Section 
>>> biometrics, methodology and quality assurance Gaverstraat 4 9500 
>>> Geraardsbergen Belgium tel. + 32 54/436 185 
>>>       
>> Thierry.Onkelinx at inbo.be 
>>     
>>> www.inbo.be
>>>
>>> Do not put your faith in what statistics say until you have 
>>>       
>> carefully 
>>     
>>> considered what they do not say.  ~William W. Watt A statistical 
>>> analysis, properly conducted, is a delicate dissection of 
>>> uncertainties, a surgery of suppositions. ~M.J.Moroney
>>>
>>>
>>>
>>>       
>>>> -----Oorspronkelijk bericht-----
>>>> Van: Rainer M Krug [mailto:Rainer+R-help at krugs.de]
>>>> Verzonden: woensdag 17 oktober 2007 11:28
>>>> Aan: ONKELINX, Thierry
>>>> CC: Prof Brian Ripley; r-help
>>>> Onderwerp: Re: [R] One pdf file with plots and text output
>>>>
>>>> ONKELINX, Thierry wrote:
>>>>         
>>>>> I use Sweave for this kind of purposes.
>>>>>           
>>>> I was thinking about Sweave as well, but I don't 
>>>>         
>> understand how I can 
>>     
>>>> use it.
>>>>
>>>> Let's say I have a source file, which defines a function
>>>>
>>>> DoGrowthAll <- function()
>>>>    {
>>>>      pdf("GrowthAll.pdf", height=11, width=8, paper="a4")
>>>>      sink("GrowthAll.txt")
>>>>      try(
>>>>          {
>>>>            plot(x.lm)
>>>>            summary(xlm)
>>>>            .
>>>>            .
>>>>            .
>>>>          }
>>>>          )
>>>>      sink()
>>>>      dev.off()
>>>>      system("xpdf ./GrowthAll.pdf", wait=FALSE)
>>>>    }
>>>>
>>>> Now how can I use Sweave to create this report?
>>>>
>>>> Rainer
>>>>
>>>>         
>>>>> HTH,
>>>>>
>>>>> Thierry
>>>>>
>>>>>
>>>>>           
>> ---------------------------------------------------------------------
>>     
>>>> -
>>>>         
>>>>> --
>>>>> ----
>>>>> ir. Thierry Onkelinx
>>>>> Instituut voor natuur- en bosonderzoek / Research Institute
>>>>>           
>>>> for Nature
>>>>         
>>>>> and Forest Cel biometrie, methodologie en kwaliteitszorg 
>>>>>           
>> / Section 
>>     
>>>>> biometrics, methodology and quality assurance Gaverstraat 4 9500 
>>>>> Geraardsbergen Belgium tel. + 32 54/436 185
>>>>>           
>>>> Thierry.Onkelinx at inbo.be
>>>>         
>>>>> www.inbo.be
>>>>>
>>>>> Do not put your faith in what statistics say until you have
>>>>>           
>>>> carefully
>>>>         
>>>>> considered what they do not say.  ~William W. Watt A statistical 
>>>>> analysis, properly conducted, is a delicate dissection of 
>>>>> uncertainties, a surgery of suppositions. ~M.J.Moroney
>>>>>
>>>>>
>>>>>
>>>>>           
>>>>>> -----Oorspronkelijk bericht-----
>>>>>> Van: r-help-bounces at r-project.org
>>>>>> [mailto:r-help-bounces at r-project.org] Namens Rainer M Krug
>>>>>> Verzonden: woensdag 17 oktober 2007 11:02
>>>>>> Aan: Prof Brian Ripley
>>>>>> CC: r-help
>>>>>> Onderwerp: Re: [R] One pdf file with plots and text output
>>>>>>
>>>>>> Prof Brian Ripley wrote:
>>>>>>             
>>>>>>> On Wed, 17 Oct 2007, Rainer M Krug wrote:
>>>>>>>
>>>>>>>               
>>>>>>>> Hi
>>>>>>>>
>>>>>>>> I create one pdf file with plots via pdf() and one text
>>>>>>>>                 
>>>> file with
>>>>         
>>>>>>>> text via sink() that works very nice. But I would prefer
>>>>>>>>                 
>>>>>> to have one
>>>>>>             
>>>>>>>> pdf file with plots and the text which I store in the
>>>>>>>>                 
>>>>>> te=xt file via sink(). I.e.
>>>>>>             
>>>>>>>> x.lm<-lm(...)
>>>>>>>> pdf()
>>>>>>>> plot(x.lm)
>>>>>>>> NOW THE TEXT OF summary(xlm) IN THE PDF FILE
>>>>>>>> dev.off()
>>>>>>>>
>>>>>>>> Is this possible or is there a different format which I
>>>>>>>>                 
>>>> could use?
>>>>         
>>>>>>> You can easily post-process the files to obtain a single
>>>>>>>               
>>>>>> file.  Going
>>>>>>             
>>>>>>> from text to pdf involves many arbitrary choices, but a 
>>>>>>>               
>> good text 
>>     
>>>>>>> processor will help you make those and incorporate pdf 
>>>>>>>               
>> figures: I 
>>     
>>>>>>> would use pdflatex, but there are many other tools to 
>>>>>>>               
>> do the job.
>>     
>>>>>> Thanks for pointing out the post-processing route (I have done 
>>>>>> similar script based pdf creations via pdflatex before),
>>>>>>             
>>>> but I would
>>>>         
>>>>>> like to have something only for me to make it easier to read the 
>>>>>> results.
>>>>>> It does not need to be nicely layouted - just the text in
>>>>>>             
>>>> the pdf in
>>>>         
>>>>>> whatever font would be fine.
>>>>>>
>>>>>> ______________________________________________
>>>>>> 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.
>>>>>           
>>> ______________________________________________
>>> 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.
>
>   


-- 
Mango Solutions
data analysis that delivers

Tel:  +44(0) 1249 467 467
Fax:  +44(0) 1249 467 468
Mob:  +44(0) 7813 526 123



More information about the R-help mailing list