[R] Fw: Save multiple plots as pdf or jpeg

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Wed Apr 23 11:44:33 CEST 2014

Have a look at the knitr package. http://yihui.name/knitr/demo/minimal/

Best regards,

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
+ 32 2 525 02 51
+ 32 54 43 61 85
Thierry.Onkelinx at inbo.be

To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

-----Oorspronkelijk bericht-----
Van: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Namens Pavneet Arora
Verzonden: woensdag 23 april 2014 11:14
Aan: Jeff Newmiller
CC: r-help at r-project.org
Onderwerp: Re: [R] Fw: Save multiple plots as pdf or jpeg

Sorry I should have been more clearer. Let me repharse.

At the moment I have a loop that plots a histogram of the variable, along with rug and super-imposed normal curve over it. It does that for a lot of variables in the dataset and then compiles them into a pdf. Whereby each page on the pdf corresponds to the histogram of 1 variable.

However, it takes ages to load and takes up a lot of memory. So I was wondering if there is a way that before it gets compiled into a pdf, if I can convert my graphs into png or bitmaps images and then compile them into pdf?

This is my code so far:

pdf(file="C:/#temp/Histo and2.pdf") ##- Saves all plots in the same pdf file
for(k in 1:ncol(nums2)){    hist(nums2[,k],freq=F,col="lightblue1",
#density=20   ##- Density -> Gives shaded bars
                                 xlab=names(nums2)[k])  ##- Font=2 => bold


 lines(density(nums2[,k],na.rm=T),col="navy",lwd=2)          ##- Density
Function of data


                            #  readline(prompt="Press [enter] to
Hope this is much clearer?

From:   Jeff Newmiller <jdnewmil at dcn.davis.CA.us>
To:     Pavneet Arora/UK/RoyalSun at RoyalSun, r-help at r-project.org
Date:   22/04/2014 16:09
Subject:        Re: [R] Fw: Save multiple plots as pdf or jpeg

Sounds like you are getting what you want... except that you used the word
"but". If you are not getting what you want, then what is it that you do
want? In particular, how do you intend to review or use many plots
generated at once if not in a PDF file?
Jeff Newmiller                        The     .....       .....  Go
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#. rocks...1k

Sent from my phone. Please excuse my brevity.

On April 22, 2014 6:59:55 AM PDT, starter <pavneet.arora at uk.rsagroup.com>
>That is what I was trying to achieve; i.e. plot all my graphs using a
>function. But somewhere in the loop it converts each graph into png or
>bitmap image and then compiles all these png or bitmap images in a pdf
>So each page in a pdf file is a bitmap or png picture of my graph.
>Does that make any sense?
>View this message in context:

>Sent from the R help mailing list archive at Nabble.com.
>R-help at r-project.org mailing list
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.


The following message has been automatically added to comply with the RSA
Group IT Security requirements:

This email arrived via the internet, over a secure Opportunistic TLS
encryption connection.
This means the email was sent using encryption but the senders domain has
not been verified for its authenticity.
As such you still need to be cautious about its origin and content.
Replies which contain sensitive information or legal/contractual
obligations are particularly vulnerable.
In these cases you should not reply unless you are authorised to do so.

If you have any questions, please speak to the Service Centre on x7979.

MORE TH>N is a trading style of Royal & Sun Alliance Insurance plc (No. 93792). Registered in England and Wales at St. Mark’s Court, Chart Way, Horsham, West Sussex, RH12 1XL.

Authorised by the Prudential Regulation Authority and regulated by the Financial Conduct Authority and the Prudential Regulation Authority.

        [[alternative HTML version deleted]]

* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document.

More information about the R-help mailing list