Re: [sage-support] Re: examples of using R

2010-01-29 Thread Ondrej Certik
Hi,

On Fri, Jan 29, 2010 at 5:27 AM, kcrisman  wrote:
> Another thing you can do is type r.?  and you will get a lot of
> commands which "should work".  In my experience, though, it's not
> always obvious how to use every command - sometimes arguments in R
> need to be input as strings, for instance, though definitely not
> always.  On the plus side, the R help works more or less as
> advertised.  I'm not sure why Pedro needs to have everything RDF or
> _sage_ to go back and forth; that should be taken care of in the R
> interpreter, as long as your inputs are reals when you run the script
> - ?
>
> When the next version of Sage comes out, we will also finally have all
> recommended packages installed, so it should become much easier to use
> it.
>
> And of course Gokhan's idea is also a very good one, to use the r
> option (or %r, I think, in an individual cell) in the notebook.

Thanks all of you for the useful input. It works for me. The reason I
asked is that I was that we just presented how to use FEMhub
(femhub.org), which is based on Sage (it doesn't contain R though) at
our colloquium, and then I was in the computer lab and one professor
was teaching statistics in R, explaining how to download/install it,
and then they were using it as a desktop application, so I had first
hand experience how people use R.

And I am glad I use Python. The devil is in the details. So I will
mention Sage to him together with some examples how to use R in it.

Ondrej

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: examples of using R

2010-01-29 Thread kcrisman
Another thing you can do is type r.?  and you will get a lot of
commands which "should work".  In my experience, though, it's not
always obvious how to use every command - sometimes arguments in R
need to be input as strings, for instance, though definitely not
always.  On the plus side, the R help works more or less as
advertised.  I'm not sure why Pedro needs to have everything RDF or
_sage_ to go back and forth; that should be taken care of in the R
interpreter, as long as your inputs are reals when you run the script
- ?

When the next version of Sage comes out, we will also finally have all
recommended packages installed, so it should become much easier to use
it.

And of course Gokhan's idea is also a very good one, to use the r
option (or %r, I think, in an individual cell) in the notebook.

- kcrisman

On Jan 29, 6:49 am, jpc  wrote:
> Hi,
>
> I've search on
>    http://rpy.sourceforge.net/
> and use R with commands inside a Sage script as following:
>
> from sage.all import *
>
> def iunif(a,b):
>     return Integer(fround(r.runif(1,RDF(a),RDF(b)),0))
> def runif(a,b,prec):
>     return RDF(fround(r.runif(1,RDF(a),RDF(b)),prec))
> def rbernoulli():
>     return r.rbinom(1, 1, 0.5)._sage_()
>
> From Sage I've used RDF because R needs "reals" and not symbolic
> expressions and used _sage_() to convert from R objects to Sage
> objects.
>
> I have problems with:
>  r.set_seed => accept only one argument
>  r graphics => could not got them to appear in Sage environment.
>
> I'm no expert in Sage so I welcome any suggestion to improve the above
> commands.
>
> Pedro Cruz
>
> On Jan 29, 4:02 am, Gokhan Sever  wrote:
>
>
>
>
>
> > On Jan 28, 8:00 pm, Ondrej Certik  wrote:
>
> > > Hi,
>
> > > are there some examples how to use R from Sage?
>
> > > I tried to search here:
>
> > >http://www.sagemath.org/help.html
>
> > >http://www.sagemath.org/doc/reference/
>
> > > I also tried to search sage-devel, for "R" and "R statistics" and "R
> > > statistical", but didn't find anything. So the next time, I'll at
> > > least find my own message, and hopefully some hints. :)
>
> > > Ondrej
>
> > Hi Ondrej,
>
> > A couple sources I can point out:
>
> >http://sage.math.washington.edu/home/mhansen/sage-epydoc/sage.interfa...
> > (Interestingly this doesn't show up on the main reference 
> > --http://www.sagemath.org/doc/reference/interfaces.html)
> > Might need to let SAGE guys know about this, on sage-devel or open a
> > documentation enhancement etc. :)
>
> >http://groups.google.com/group/sage-support/browse_thread/thread/53d6...
>
> > Also sage-notebook has an "r" mode you can directly enter "R"
> > commands.
>
> > y <- c(1, 2, 3) instead of y = r("c(1, 2, 3)")
>
> > I know it is tricky to search terms like "R" or "C". Python is very
> > easy to find although at time it interferes with the snake and
> > monthy :)
>
> On Jan 29, 4:02 am, Gokhan Sever  wrote:
>
>
>
> > On Jan 28, 8:00 pm, Ondrej Certik  wrote:
>
> > > Hi,
>
> > > are there some examples how to use R from Sage?
>
> > > I tried to search here:
>
> > >http://www.sagemath.org/help.html
>
> > >http://www.sagemath.org/doc/reference/
>
> > > I also tried to search sage-devel, for "R" and "R statistics" and "R
> > > statistical", but didn't find anything. So the next time, I'll at
> > > least find my own message, and hopefully some hints. :)
>
> > > Ondrej
>
> > Hi Ondrej,
>
> > A couple sources I can point out:
>
> >http://sage.math.washington.edu/home/mhansen/sage-epydoc/sage.interfa...
> > (Interestingly this doesn't show up on the main reference 
> > --http://www.sagemath.org/doc/reference/interfaces.html)
> > Might need to let SAGE guys know about this, on sage-devel or open a
> > documentation enhancement etc. :)
>
> >http://groups.google.com/group/sage-support/browse_thread/thread/53d6...
>
> > Also sage-notebook has an "r" mode you can directly enter "R"
> > commands.
>
> > y <- c(1, 2, 3) instead of y = r("c(1, 2, 3)")
>
> > I know it is tricky to search terms like "R" or "C". Python is very
> > easy to find although at time it interferes with the snake and
> > monthy :)

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: examples of using R

2010-01-29 Thread jpc
Hi,

I've search on
   http://rpy.sourceforge.net/
and use R with commands inside a Sage script as following:

from sage.all import *

def iunif(a,b):
return Integer(fround(r.runif(1,RDF(a),RDF(b)),0))
def runif(a,b,prec):
return RDF(fround(r.runif(1,RDF(a),RDF(b)),prec))
def rbernoulli():
return r.rbinom(1, 1, 0.5)._sage_()

>From Sage I've used RDF because R needs "reals" and not symbolic
expressions and used _sage_() to convert from R objects to Sage
objects.

I have problems with:
 r.set_seed => accept only one argument
 r graphics => could not got them to appear in Sage environment.

I'm no expert in Sage so I welcome any suggestion to improve the above
commands.

Pedro Cruz



On Jan 29, 4:02 am, Gokhan Sever  wrote:
> On Jan 28, 8:00 pm, Ondrej Certik  wrote:
>
> > Hi,
>
> > are there some examples how to use R from Sage?
>
> > I tried to search here:
>
> >http://www.sagemath.org/help.html
>
> >http://www.sagemath.org/doc/reference/
>
> > I also tried to search sage-devel, for "R" and "R statistics" and "R
> > statistical", but didn't find anything. So the next time, I'll at
> > least find my own message, and hopefully some hints. :)
>
> > Ondrej
>
> Hi Ondrej,
>
> A couple sources I can point out:
>
> http://sage.math.washington.edu/home/mhansen/sage-epydoc/sage.interfa...
> (Interestingly this doesn't show up on the main reference 
> --http://www.sagemath.org/doc/reference/interfaces.html)
> Might need to let SAGE guys know about this, on sage-devel or open a
> documentation enhancement etc. :)
>
> http://groups.google.com/group/sage-support/browse_thread/thread/53d6...
>
> Also sage-notebook has an "r" mode you can directly enter "R"
> commands.
>
> y <- c(1, 2, 3) instead of y = r("c(1, 2, 3)")
>
> I know it is tricky to search terms like "R" or "C". Python is very
> easy to find although at time it interferes with the snake and
> monthy :)

On Jan 29, 4:02 am, Gokhan Sever  wrote:
> On Jan 28, 8:00 pm, Ondrej Certik  wrote:
>
> > Hi,
>
> > are there some examples how to use R from Sage?
>
> > I tried to search here:
>
> >http://www.sagemath.org/help.html
>
> >http://www.sagemath.org/doc/reference/
>
> > I also tried to search sage-devel, for "R" and "R statistics" and "R
> > statistical", but didn't find anything. So the next time, I'll at
> > least find my own message, and hopefully some hints. :)
>
> > Ondrej
>
> Hi Ondrej,
>
> A couple sources I can point out:
>
> http://sage.math.washington.edu/home/mhansen/sage-epydoc/sage.interfa...
> (Interestingly this doesn't show up on the main reference 
> --http://www.sagemath.org/doc/reference/interfaces.html)
> Might need to let SAGE guys know about this, on sage-devel or open a
> documentation enhancement etc. :)
>
> http://groups.google.com/group/sage-support/browse_thread/thread/53d6...
>
> Also sage-notebook has an "r" mode you can directly enter "R"
> commands.
>
> y <- c(1, 2, 3) instead of y = r("c(1, 2, 3)")
>
> I know it is tricky to search terms like "R" or "C". Python is very
> easy to find although at time it interferes with the snake and
> monthy :)

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: examples of using R

2010-01-28 Thread Gokhan Sever


On Jan 28, 8:00 pm, Ondrej Certik  wrote:
> Hi,
>
> are there some examples how to use R from Sage?
>
> I tried to search here:
>
> http://www.sagemath.org/help.html
>
> http://www.sagemath.org/doc/reference/
>
> I also tried to search sage-devel, for "R" and "R statistics" and "R
> statistical", but didn't find anything. So the next time, I'll at
> least find my own message, and hopefully some hints. :)
>
> Ondrej

Hi Ondrej,

A couple sources I can point out:

http://sage.math.washington.edu/home/mhansen/sage-epydoc/sage.interfaces.r-module.html
(Interestingly this doesn't show up on the main reference --
http://www.sagemath.org/doc/reference/interfaces.html)
Might need to let SAGE guys know about this, on sage-devel or open a
documentation enhancement etc. :)

http://groups.google.com/group/sage-support/browse_thread/thread/53d6a95c0f9a2ab4/ac6ee4fbb03c34db?#ac6ee4fbb03c34db

Also sage-notebook has an "r" mode you can directly enter "R"
commands.

y <- c(1, 2, 3) instead of y = r("c(1, 2, 3)")

I know it is tricky to search terms like "R" or "C". Python is very
easy to find although at time it interferes with the snake and
monthy :)

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org