Knut Ivar Nesheim wrote:
> Den 9. mars. 2008 kl. 19.52 skrev Barry Rowlingson:
>
>   
>> Knut Ivar Nesheim wrote:
>>
>>     
>>> Let's say I have a list of data, [10.5, 11.3, 10.2, None, 10.7] and
>>> I'm using r.plot(data, type = "l"), None will be treated as 0.0
>>> instead of just empty. Same thing if I use type = "o" or whatever.
>>>
>>> I want the line just to stop where there's no data and then continue
>>> again where I have some data. How would I do that?
>>>
>>>       
>>  In R, you do this with the 'NA' value. You can get this from rpy with
>> rpy.NA:
>>
>>     
>>>>> from rpy import r
>>>>> x=[1,2,3,4,5,6,7,8,9,10]
>>>>> y=[5,4,3,4,5,6,r.NA,7,4,3]
>>>>> r.plot(x,y)
>>>>> r.lines(x,y)
>>>>>           
>> rpy.NA seems to be a large negative integer, since I think Python
>> doesn't support standard NA or NaN values. Perhaps the best thing to  
>> do
>> is keep values as None and convert to rpy.NA at the last possible
>> moment. Must be something in the docs...
>>     
>
>   
there's another way.  use the rpy's NaN (or numpy's nan):

import rpy # import numpy
x = range(10)
x[5] = rpy.NaN  # x[5] = numpy.nan
rpy.r.plot(x)
rpy.r.lines(x)


(used long names for clarity)
vQ

-- 
-------------------------------------------------------------------------------
Wacek Kusnierczyk, MD MSc

Email: [EMAIL PROTECTED]
Phone: +47 73591875, +47 72574609

Department of Computer and Information Science (IDI)
Faculty of Information Technology, Mathematics and Electrical Engineering (IME)
Norwegian University of Science and Technology (NTNU)
Sem Saelands vei 7, 7491 Trondheim, Norway
Room itv303

Bioinformatics & Gene Regulation Group
Department of Cancer Research and Molecular Medicine (IKM)
Faculty of Medicine (DMF)
Norwegian University of Science and Technology (NTNU)
Laboratory Center, Erling Skjalgsons gt. 1, 7030 Trondheim, Norway
Room 231.05.060

-------------------------------------------------------------------------------


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
rpy-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to