[BioC] save R graphics device output in a file
Sean Davis
sdavis2 at mail.nih.gov
Mon Apr 14 22:10:18 CEST 2008
On Mon, Apr 14, 2008 at 4:01 PM, carol white <wht_crl at yahoo.com> wrote:
> Thanks for your reply.
>
> I wrote a script, namely my_script and run it as
> R < my_script > res --no-save &
>
> my_script contains:
>
> library (geneplotter)
> library (grDevices)
> hist (mat) # mat is a matrix
> savepng ("Rtmp", ".")
> dev.off()
> q("no")
Try:
png('stuff.png')
hist(mat)
dev.off()
> ***********************************3
> so Rtmp.png is created at the end but with 0 byte and res (output file) contains:
> > library (geneplotter)
> > library (grDevices)
> > hist (mat)
> > savepng ("Rtmp", ".")
> [1] "./Rtmp.png"
> > dev.off()
> null device
> 1
> > q("no")
>
>
> but when running in R:
> *****************************
> library (geneplotter)
> Loading required package: annotate
> Loading required package: Biobase
> Loading required package: tools
>
> Welcome to Bioconductor
>
> Vignettes contain introductory material. To view, type
> 'openVignette()'. To cite Bioconductor, see
> 'citation("Biobase")' and for packages 'citation(pkgname)'.
>
> Loading required package: lattice
> KernSmooth 2.22 installed
> Copyright M. P. Wand 1997
> > library (grDevices)
> > hist (mat)
> > savepng ("Rtmp", ".")
> [1] "./Rtmp.png"
> > dev.off()
> null device
> 1
> > q("no")
>
> ./Rtmp.png is created correctly (a non-zero byte image)
>
> I use R 2.5.1
>
> thanks
>
> Florian Hahne <fhahne at fhcrc.org> wrote: Hi Carol,
> In order to save graphics on a file device you need to properly close
> this device after the plotting, that is, use dev.off() I am not sure
> what you mean by "running R in the background". Did you start it via R
> CMD batch or something similar as a background process? In any case,
> the proper use of jpeg() and dev.off() should create a valid image
> file irespective of that, unless you are on remote machine without x11
> port forwarding, which again should result in a number of errors.
> Sending a brief example of code that illustrates your problem and at
> least some information about your R version would also help
> Cheers
> Florian
>
>
>
> On 14.04.2008, at 08:22, carol white wrote:
>
> > Hi,
> > I tried to use savepng (library geneplotter) or jpeg (grDevices) to
> > save the R output image in a file. When I run R in foreground,
> > savepng saves the image in a file but when I run R in background (in
> > a unix terminal shell), a file is created but with 0 byte. When the
> > jpeg is used in R in bg or fg, a file is created with 0 byte. Why is
> > the image not saved when I run the R in bg?
> >
> > Regards,
> >
> > carol
> >
> >
> >
> >
> >
> > ____________________________________________________________________________________
>
>
> > Be a better friend, newshound, and
> >
> > [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > Bioconductor mailing list
> > Bioconductor at stat.math.ethz.ch
> > https://stat.ethz.ch/mailman/listinfo/bioconductor
> > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor
>
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor
>
More information about the Bioconductor
mailing list