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 <[email protected]> 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 <[email protected]> wrote:
>
>
>
>
>
> > On Jan 28, 8:00 pm, Ondrej Certik <[email protected]> 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 <[email protected]> wrote:
>
>
>
> > On Jan 28, 8:00 pm, Ondrej Certik <[email protected]> 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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to