On 05/20/2010 01:33 PM, Nathann Cohen wrote:

The
manipulation of matrices in R is just amazing. If you want to strip
all the negative values contained in a matrix M, you but have to write
M * (M>  0). How easier can it et ?


Here is the amazing numpy at work:

sage: a=random_matrix(ZZ,5).numpy();
sage: a<0
array([[ True, False,  True,  True, False],
       [ True, False, False,  True,  True],
       [False,  True,  True, False, False],
       [ True, False, False,  True, False],
       [ True, False,  True,  True,  True]], dtype=bool)
sage: a[a<0]=0
sage: a
array([[ 0,  1,  0,  0,  3],
       [ 0,  2,  1,  0,  0],
       [ 2,  0,  0, 25,  1],
       [ 0,  1,  2,  0,  9],
       [ 0,  1,  0,  0,  0]])


I would like to do something like that in Sage. We have some of the framework in place, but when we do a comparison with a matrix, we don't do it element-wise. In fact, I'm not sure what we do:

sage: b
[ 0  1  0  0  3]
[ 0  2  1  0  0]
[ 2  0  0 25  1]
[ 0  1  2  0  9]
[ 0  1  0  0  0]
sage: b>1
False

What in the world does that mean?


There is a thousand tricks like
that available in R that I noticed nowhere else.

Matlab/Octave and numpy both have a huge amount of tricks like the above as well.


And the same goes for
plottings using R. I mean that on these two points, the R language is
much more expressive than any other I know.


I really like the plotting in R. Kudos to Karl-Dieter and others for working on getting the R plotting to work nicely in the Sage notebook!

Another reason I like R in teaching is that it comes with a huge number of real-life datasets.

Jason

--
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

Reply via email to