Re: [R] Calling R from a non-X shell script to plot?

2004-12-13 Thread doktora v
Ah, that's great. I was halfway on my way writing this out... 
Thanks, much appreciated!

-- dok


On Mon, 13 Dec 2004 13:51:00 -0800, Joe Conway <[EMAIL PROTECTED]> wrote:
> Seth Falcon wrote:
> > On Mon, Dec 13, 2004 at 12:25:01PM -0500, doktora v wrote:
> >
> >>Is anyone familiar with this (i.e. running R from a non-X
> >>environment)? Is there  a way to get around this? I've seen some stuff
> >>about virtual devices,  but have no idea if it works or where to
> >>start. If there is a simpler solution, please let me know.
> >
> > I've used Xvfb in this situation.  After installing Xvfb, you can do
> > something like this:
> >
> > Xvfb :15&
> > export DISPLAY=localhost:15
> > # Run R
> 
> FWIW, here's what I've used in the past for an Xvfb init script:
> 
> 8<
> #!/bin/bash
> #
> # syslogStarts Xvfb.
> #
> #
> # chkconfig: 2345 12 88
> # description: Xvfb is a facility that applications requiring an X frame
> buffer \
> # can use in place of actually running X on the server
> 
> # Source function library.
> . /etc/init.d/functions
> 
> [ -f /usr/X11R6/bin/Xvfb ] || exit 0
> 
> XVFB="/usr/X11R6/bin/Xvfb :5 -screen 0 1024x768x16"
> 
> RETVAL=0
> 
> umask 077
> 
> start() {
>  echo -n $"Starting Xvfb: "
>  $XVFB&
>  RETVAL=$?
>  echo_success
>  echo
>  [ $RETVAL = 0 ] && touch /var/lock/subsys/Xvfb
>  return $RETVAL
> }
> stop() {
>  echo -n $"Shutting down Xvfb: "
>  killproc Xvfb
>  RETVAL=$?
>  echo
>  [ $RETVAL = 0 ] && rm -f /var/lock/subsys/Xvfb
>  return $RETVAL
> }
> restart() {
>  stop
>  start
> }
> 
> case "$1" in
>start)
>  start
>  ;;
>stop)
>  stop
>  ;;
>restart|reload)
>  restart
>  ;;
>condrestart)
>  [ -f /var/lock/subsys/Xvfb ] && restart || :
>  ;;
>*)
>  echo $"Usage: $0 {start|stop|restart|condrestart}"
>  exit 1
> esac
> 
> exit $RETVAL
> 8<-
> 
> HTH,
> 
> Joe
> 
> __
> [EMAIL PROTECTED] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Calling R from a non-X shell script to plot?

2004-12-13 Thread Rajarshi Guha
On Mon, 2004-12-13 at 12:25 -0500, doktora v wrote:
> I am trying to run R from an apache C++ module in a shell script to
> plot some data to display it in apache later. I get the error
> (reported in apache's logs):
> 
> Xlib: connection to ":0.0" refused by server
> Xlib: No protocol specified
> Error in X11(paste("png::", filename, sep = ""), width, height, pointsize,  :
>   unable to start device PNG
> In addition: Warning message:
> unable to open connection to X11 display`'
> Execution halted
> 
> Is anyone familiar with this (i.e. running R from a non-X
> environment)? Is there  a way to get around this? I've seen some stuff
> about virtual devices,  but have no idea if it works or where to
> start. If there is a simpler solution, please let me know.

I use the following when I need to plot a graphic by calling R from a
PHP script on my webserver

bitmap(file=plotfile, height=7, width=7)
par(pch=19, col='black', cex=1.5)
plot(log(1/boxsize), log(bv), ylab="log(box count)", xlab="log(1/box
size)")

---
Rajarshi Guha <[EMAIL PROTECTED]> 
GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE
---
A list is only as strong as its weakest link.
-- Don Knuth

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Calling R from a non-X shell script to plot?

2004-12-13 Thread Joe Conway
Seth Falcon wrote:
On Mon, Dec 13, 2004 at 12:25:01PM -0500, doktora v wrote:
Is anyone familiar with this (i.e. running R from a non-X
environment)? Is there  a way to get around this? I've seen some stuff
about virtual devices,  but have no idea if it works or where to
start. If there is a simpler solution, please let me know.
I've used Xvfb in this situation.  After installing Xvfb, you can do
something like this:
Xvfb :15&
export DISPLAY=localhost:15
# Run R 
FWIW, here's what I've used in the past for an Xvfb init script:
8<
#!/bin/bash
#
# syslogStarts Xvfb.
#
#
# chkconfig: 2345 12 88
# description: Xvfb is a facility that applications requiring an X frame 
buffer \
# can use in place of actually running X on the server

# Source function library.
. /etc/init.d/functions
[ -f /usr/X11R6/bin/Xvfb ] || exit 0
XVFB="/usr/X11R6/bin/Xvfb :5 -screen 0 1024x768x16"
RETVAL=0
umask 077
start() {
echo -n $"Starting Xvfb: "
$XVFB&
RETVAL=$?
echo_success
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/Xvfb
return $RETVAL
}
stop() {
echo -n $"Shutting down Xvfb: "
killproc Xvfb
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/Xvfb
return $RETVAL
}
restart() {
stop
start
}
case "$1" in
  start)
start
;;
  stop)
stop
;;
  restart|reload)
restart
;;
  condrestart)
[ -f /var/lock/subsys/Xvfb ] && restart || :
;;
  *)
echo $"Usage: $0 {start|stop|restart|condrestart}"
exit 1
esac
exit $RETVAL
8<-
HTH,
Joe
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Calling R from a non-X shell script to plot?

2004-12-13 Thread doktora v
Thank, 
bitmap produces huge and empty files. it could be my ghostscript, but
there is no way to really tell, it's the latest version will try
Xvfb


On Mon, 13 Dec 2004 12:57:47 -0500, Liaw, Andy <[EMAIL PROTECTED]> wrote:
> See
> http://cran.us.r-project.org/doc/FAQ/R-FAQ.html#How-do-I-produce-PNG-graphic
> s-in-batch-mode_003f
> 
> Andy
> 
> > From: doktora v
> >
> > I am trying to run R from an apache C++ module in a shell script to
> > plot some data to display it in apache later. I get the error
> > (reported in apache's logs):
> >
> > Xlib: connection to ":0.0" refused by server
> > Xlib: No protocol specified
> > Error in X11(paste("png::", filename, sep = ""), width,
> > height, pointsize,  :
> >   unable to start device PNG
> > In addition: Warning message:
> > unable to open connection to X11 display`'
> > Execution halted
> >
> > Is anyone familiar with this (i.e. running R from a non-X
> > environment)? Is there  a way to get around this? I've seen some stuff
> > about virtual devices,  but have no idea if it works or where to
> > start. If there is a simpler solution, please let me know.
> >
> > -- doktora
> >
> >
> > I run the following shell script from the apache module using execve:
> > --
> > DISPLAY=:0.0
> > export DISPLAY
> >
> > if $R --vanilla --quiet < $rfile >$log ; then
> >   echo "Success"
> > else
> >   echo "There were errors in $0, see $log"
> > fi
> > --
> >
> > And $rfile contains this:
> > --
> > png(filename = "/tmp/plot.png", width = 510, height = 360);
> > plot()
> > dev.off()
> > 
> > __
> > [EMAIL PROTECTED] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> > http://www.R-project.org/posting-guide.html
> >
> >
> 
> --
> Notice:  This e-mail message, together with any attachment...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Calling R from a non-X shell script to plot?

2004-12-13 Thread Seth Falcon
On Mon, Dec 13, 2004 at 12:25:01PM -0500, doktora v wrote:
> Is anyone familiar with this (i.e. running R from a non-X
> environment)? Is there  a way to get around this? I've seen some stuff
> about virtual devices,  but have no idea if it works or where to
> start. If there is a simpler solution, please let me know.

I've used Xvfb in this situation.  After installing Xvfb, you can do
something like this:

Xvfb :15&
export DISPLAY=localhost:15
# Run R 

+ seth

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Calling R from a non-X shell script to plot?

2004-12-13 Thread Rajarshi Guha
On Mon, 2004-12-13 at 12:25 -0500, doktora v wrote:
> I am trying to run R from an apache C++ module in a shell script to
> plot some data to display it in apache later. I get the error
> (reported in apache's logs):
> 
> Xlib: connection to ":0.0" refused by server
> Xlib: No protocol specified
> Error in X11(paste("png::", filename, sep = ""), width, height, pointsize,  :
>   unable to start device PNG
> In addition: Warning message:
> unable to open connection to X11 display`'
> Execution halted

I use the following when I need to plot a graphic by calling R from a
PHP script on my webserver

bitmap(file=plotfile, height=7, width=7)
par(pch=19, col='black', cex=1.5)
plot(log(1/boxsize), log(bv), ylab="log(box count)", xlab="log(1/box
size)")

---
Rajarshi Guha <[EMAIL PROTECTED]> 
GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE
---
Science kind of takes the fun out of the portent business.
-Hobbes

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Calling R from a non-X shell script to plot?

2004-12-13 Thread doktora v
So, it turns out that using Xvfb is quite simple and works great (fast).

To summ up: if you are trying to plot a png file from a non-X environment, 
run Xvfb, like so (for example):

Xvfb :9 -screen 0 800x600x16&

This will run a virtual X server 9 with screen 0.
In your shell script (or whatever other environment you are using),
set the DISPLAY environment variable to :9.0:
DISPLAY=:9.0
export DISPLAY

presto 
-- dok


On Mon, 13 Dec 2004 13:32:23 -0500, Rajarshi Guha <[EMAIL PROTECTED]> wrote:
> On Mon, 2004-12-13 at 12:25 -0500, doktora v wrote:
> > I am trying to run R from an apache C++ module in a shell script to
> > plot some data to display it in apache later. I get the error
> > (reported in apache's logs):
> >
> > Xlib: connection to ":0.0" refused by server
> > Xlib: No protocol specified
> > Error in X11(paste("png::", filename, sep = ""), width, height, pointsize,  
> > :
> >   unable to start device PNG
> > In addition: Warning message:
> > unable to open connection to X11 display`'
> > Execution halted
> 
> I use the following when I need to plot a graphic by calling R from a
> PHP script on my webserver
> 
> bitmap(file=plotfile, height=7, width=7)
> par(pch=19, col='black', cex=1.5)
> plot(log(1/boxsize), log(bv), ylab="log(box count)", xlab="log(1/box
> size)")
> 
> ---
> Rajarshi Guha <[EMAIL PROTECTED]> 
> GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE
> ---
> Science kind of takes the fun out of the portent business.
> -Hobbes
> 
>

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] Calling R from a non-X shell script to plot?

2004-12-13 Thread Liaw, Andy
See
http://cran.us.r-project.org/doc/FAQ/R-FAQ.html#How-do-I-produce-PNG-graphic
s-in-batch-mode_003f

Andy

> From: doktora v
> 
> I am trying to run R from an apache C++ module in a shell script to
> plot some data to display it in apache later. I get the error
> (reported in apache's logs):
> 
> Xlib: connection to ":0.0" refused by server
> Xlib: No protocol specified
> Error in X11(paste("png::", filename, sep = ""), width, 
> height, pointsize,  :
>   unable to start device PNG
> In addition: Warning message:
> unable to open connection to X11 display`'
> Execution halted
> 
> Is anyone familiar with this (i.e. running R from a non-X
> environment)? Is there  a way to get around this? I've seen some stuff
> about virtual devices,  but have no idea if it works or where to
> start. If there is a simpler solution, please let me know.
> 
> -- doktora
> 
> 
> I run the following shell script from the apache module using execve:
> --
> DISPLAY=:0.0
> export DISPLAY
> 
> if $R --vanilla --quiet < $rfile >$log ; then
>   echo "Success"
> else
>   echo "There were errors in $0, see $log"
> fi
> --
> 
> And $rfile contains this:
> --
> png(filename = "/tmp/plot.png", width = 510, height = 360);
> plot()
> dev.off()
> 
> __
> [EMAIL PROTECTED] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
>

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Calling R from a non-X shell script to plot?

2004-12-13 Thread doktora v
I am trying to run R from an apache C++ module in a shell script to
plot some data to display it in apache later. I get the error
(reported in apache's logs):

Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified
Error in X11(paste("png::", filename, sep = ""), width, height, pointsize,  :
  unable to start device PNG
In addition: Warning message:
unable to open connection to X11 display`'
Execution halted

Is anyone familiar with this (i.e. running R from a non-X
environment)? Is there  a way to get around this? I've seen some stuff
about virtual devices,  but have no idea if it works or where to
start. If there is a simpler solution, please let me know.

-- doktora


I run the following shell script from the apache module using execve:
--
DISPLAY=:0.0
export DISPLAY

if $R --vanilla --quiet < $rfile >$log ; then
  echo "Success"
else
  echo "There were errors in $0, see $log"
fi
--

And $rfile contains this:
--
png(filename = "/tmp/plot.png", width = 510, height = 360);
plot()
dev.off()

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html