graphic with R statistic program

38 views
Skip to first unread message

Vincent Delecroix

unread,
Oct 20, 2009, 12:24:47 PM10/20/09
to sage-support
Hi,

I'm working on simple statistic example for which I use the SAGE
interface of the R program. I'm not able to plot a graphic.

In R we use :
{{{
R: x <- (1, 1, 1, 2, 3, 3, 4, 5, 5, 6)
R: hist(x)
}}}

I try the following in SAGE (version 4.1) :
{{{
sage: x = r("c(1, 1, 1, 2, 3, 3, 4, 5, 5, 6)")
sage: r.hist(x)
...
}}

The last command returns a strange objects, which does not plot
anything ! In the documentation string of the r.hist object, it is
asked to set a plot parameter to TRUE (in upper case, which is the R
syntax). I tried the following without success :
{{{
sage: r.hist(x, plot=True)
...
}}}

Does anybody know how to use graphic functions from R ?

Thanks,
Vincent

Dag Sverre Seljebotn

unread,
Oct 23, 2009, 8:46:37 AM10/23/09
to sage-s...@googlegroups.com

You probably need to set up a graphics device. Try e.g

r.png('testfile.png')
# then plot
# then:
r.dev_off()

Dag Sverre

Vincent Delecroix

unread,
Oct 31, 2009, 3:20:28 PM10/31/09
to sage-support
On 23 oct, 13:46, Dag Sverre Seljebotn <da...@student.matnat.uio.no>
wrote:
> Vincent Delecroix wrote:
> > Hi,
>
> > I'm working on simplestatisticexample for which I use the SAGE
> > interface of theRprogram. I'm not able to plot a graphic.
>
> > InRwe use :
> > {{{
> >R: x <- (1, 1, 1, 2, 3, 3, 4, 5, 5, 6)
> >R: hist(x)
> > }}}
>
> > I try the following in SAGE (version 4.1) :
> > {{{
> > sage: x =r("c(1, 1, 1, 2, 3, 3, 4, 5, 5, 6)")
> > sage:r.hist(x)
> > ...
> > }}
>
> > The last command returns a strange objects, which does not plot
> > anything ! In the documentation string of ther.hist object, it is
> > asked to set a plot parameter to TRUE (in upper case, which is theR
> > syntax). I tried the following without success :
> > {{{
> > sage:r.hist(x, plot=True)
> > ...
> > }}}
>
> > Does anybody know how to use graphic functions fromR?
>
> You probably need to set up a graphics device. Try e.g
>
> r.png('testfile.png')
> # then plot
> # then:r.dev_off()
>
> Dag Sverre

Thank you Dag for the answer.

Unfortunately, I get
{{{
sage: r.png("tmpfile.png")
Traceback (click to the left for traceback)
...
RuntimeError: R was not compiled with PNG support
}}}

I found no help on compilation of R with png support, does any body
have a solution ?

Vincent Delecroix

unread,
Oct 31, 2009, 3:23:50 PM10/31/09
to sage-support
> I found no help on compilation ofRwithpngsupport, does any body
> have a solution ?

OK. No more answer here, there is another thread:

http://groups.google.fr/group/sage-support/browse_thread/thread/9b8f62c50f88e8eb/6ccff64e5b3fc6b2
Reply all
Reply to author
Forward
0 new messages