Grr. I need to slow down a bit. Lets see... I just tried this and it works
properly:
from rpy import *
set_default_mode(NO_CONVERSION)
x = r.matrix( r.rnorm(100), nrow=5 )
x = r.get("rownames<-")(x, ['a','b','c','d','e'] )
r.print_(x)
A similar trick can be used for column names.
On the other hand, you might find it simpler in general when dealing with R
syntax that python can't handle to create a little R function to wrap what
you want to do:
rnames = r("""
function(x,names)
{
rownames(x) <- names
x
}
""")
x = rnames(x, ['1a','2b','3c','4d','5e'])
r.print_(x)
-Greg
On 6/11/08 12:45PM , "Renato Alves" <[EMAIL PROTECTED]> wrote:
> Still can't get it to work... Am I missing something?
>
> b <- r("'rownames<-'")(b, a)
> TypeError: 'str' object is not callable
>
> I'm with RPy version 1.0.3 [R version 2.7.0 (2008-04-22)]
>
> Quoting Warnes, Gregory on 06/11/2008 05:34 PM:
>> Sorry, I gave you the wrong magic
>>
>> x <- r("'rownames<-'")(x, foo)
>>
>> -G
>>
>> On 6/11/08 12:01PM , "Renato Alves" <[EMAIL PROTECTED]> wrote:
>>
>>
>>> Hi Gregory,
>>>
>>> I've been trying to understand how to do the equivalent with the
>>> colnames function... without much success.
>>>
>>> I haven't been able to use your suggestion. I always get the error:
>>> unexpected '[' in "["
>>>
>>> Apart from this, is <- valid python syntax? Or did you meant to say = ?
>>>
>>> An example like this in the documentation would be very helpful.
>>>
>>> Thanks
>>>
>>> Quoting Gregory Warnes on 06/09/2008 05:42 PM:
>>>
>>>> As for changing he names on an existing object, you can't use the
>>>> rownames(x) <- foo syntax trick in python. Internally R converts
>>>> function calls of this sort to
>>>>
>>>> "[<-rownames"(x, foo)
>>>>
>>>> Given this fact, you can use
>>>>
>>>> x <- r("[<-rownames")(x, foo)
>>>>
>>>> to change the rownames.
>>>>
>>>> -G
>>>>
>>> -------------------------------------------------------------------------
>>> Check out the new SourceForge.net Marketplace.
>>> It's the best place to buy or sell services for
>>> just about anything Open Source.
>>> http://sourceforge.net/services/buy/index.php
>>> _______________________________________________
>>> rpy-list mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/rpy-list
>>>
>>
>>
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> rpy-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/rpy-list
--
Program Director
Center for Computational Arts, Sciences, and Engineering
Univerisity of Rochester
Tel: 585-273-2794
Fax: 585-276-2097
Email: [EMAIL PROTECTED]
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
rpy-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rpy-list