[R] Getting R to emit an image file as a pipe or Base64 stream: Mac OSX 10.3 - R 2.0.1
kee at wehi.EDU.AU
Sat Dec 4 17:48:53 CET 2004
Thanks for your replies.
The reason why I started X11.app first is because Mac OS 10.3.5 doesn't
launch X on startup, and instead uses its own Aqua/Quartz gui to render
most windows until you specifically ask for X.
The issue we're looking at is how to get R to emit the file as base64, or
to somehow hand me a pipe. Is there a way to redirect the file in jpeg()
>> From: Yuandan Zhang
>> If you want to call R from perl, why don't you do a simple
>> system call like:
>> $callR="/usr/loca/bin/R CMD BATCH plotscript.R";
>> system ($callR);
>> It is not necessary to start X display if anything can be
>> done in background
> But the problem is jpeg()/png() are not available unless an X display is
> available to the R process (one of the FAQs).
>> On Fri, 3 Dec 2004 12:07:24 +1100 (EST)
>> "Thuan-Jin Kee" <kee at wehi.EDU.AU> wrote:
>> > Hi All,
>> > Anybody know how to make R emit base64 encoded text in some
>> way that perl
>> > can grab it, instead of planting a file on your harddrive
>> when calling
>> > JPEG or PNG?
>> > I've managed to get these scripts to work and put a file on
>> the harddisk
>> > #!/usr/bin/perl -Wall
>> > # by jin kee. a simple script to demonstrate
>> > # the needed steps to get R to emit a jpeg.
>> > use strict;
>> > my($callR, $callRold);
>> > # need to start X if is isn't already started.
>> > `open /Applications/Utilities/X11.app`;
>> > #need to get let the R program know where to look
>> > #for the display immediately before calling
>> > #the R executible.
>> > $callR =<<MARKER;
>> > DISPLAY=:0.0; export DISPLAY;
>> > /usr/bin/R --vanilla <plotscript.R;
>> > MARKER
>> > system($callR);
>> > # end script
>> > #!/usr/bin/R
>> > peg("~/Desktop/test.jpg");
>> > plot(rnorm(100));
>> > dev.off();
>> > q(save = "no");
>> > My sysadmin says that the apache user can't write to the disk due to
>> > security policy, so he wants to know if I can emit the jpeg
>> as a base64
>> > stream and embedd it into the dynamically generated tag
>> using a DATA tag
>> > to inline the image.
>> > http://www.elf.org/essay/inline-image.html
>> > http://www.faqs.org/rfcs/rfc2397.html
>> > i've tried searching the R-project.org site and
>> help.search() and no luck.
>> > Yours
>> > Jin
>> > ______________________________________________
>> > R-help at stat.math.ethz.ch mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide!
>> Zhang, PhD
>> Animal Genetics and Breeding Unit
>> The University of New England
>> Armidale, NSW, Australia, 2351
>> E-mail: yzhang4 at metz.une.edu.au
>> Phone: (61) 02 6773 3786
>> Fax: (61) 02 6773 3266
>> AGBU is a joint venture of NSW Primary Industries
>> and The University of New England to undertake
>> genetic R&D for Australia's Livestock Industries
>> R-help at stat.math.ethz.ch mailing list
>> PLEASE do read the posting guide!
> R-help at stat.math.ethz.ch mailing list
> PLEASE do read the posting guide!
More information about the R-help