Re: [Rpy] From matrices to data.frames and vice versa

2011-11-28 Thread Luca Beltrame
In data lunedì 28 novembre 2011 14:51:29, Laurent Gautier ha scritto: > > then it would not matter, however (at least IMO). > Unless you have reason, you should avoid repeatedly calling "importr()" I'll try to use the KISS approach you proposed for the matrix conversion (I assume that similarly,

Re: [Rpy] From matrices to data.frames and vice versa

2011-11-28 Thread Laurent Gautier
On 2011-11-28 14:36, Luca Beltrame wrote: In data lunedì 28 novembre 2011 14:31:57, Laurent Gautier ha scritto: def as_dataframe(m): assert(isinstance(m, Matrix)) # since we did test that this is a Matrix # we may as well skip R's dispatch system res = base.as_data_frame

Re: [Rpy] From matrices to data.frames and vice versa

2011-11-28 Thread Luca Beltrame
In data lunedì 28 novembre 2011 14:31:57, Laurent Gautier ha scritto: > def as_dataframe(m): > assert(isinstance(m, Matrix)) > # since we did test that this is a Matrix > # we may as well skip R's dispatch system > res = base.as_data_frame_matrix(m) > return res At least

Re: [Rpy] From matrices to data.frames and vice versa

2011-11-28 Thread Laurent Gautier
On 2011-11-28 14:07, Luca Beltrame wrote: In data sabato 26 novembre 2011 06:53:48, Laurent Gautier ha scritto: Currently, the constructor to DataFrame accepts a "tlist" ("tagged list") as a main parameter. The idea was to be relying on duck-typing, Currently in fact I've been hitting some wal

Re: [Rpy] From matrices to data.frames and vice versa

2011-11-28 Thread Luca Beltrame
In data sabato 26 novembre 2011 06:53:48, Laurent Gautier ha scritto: > Currently, the constructor to DataFrame accepts a "tlist" ("tagged > list") as a main parameter. The idea was to be relying on duck-typing, Currently in fact I've been hitting some walls regarding that. I assume that the low

Re: [Rpy] From matrices to data.frames and vice versa

2011-11-25 Thread Laurent Gautier
On 2011-11-25 14:52, Luca Beltrame wrote: I've been looking through the code and I have a couple of questions on design. I wonder if - it is preferable to hack in a special case of "tlist" being a Matrix in the DataFrame constructor, e.g. if isinstance(tlist, Matrix); - it is preferable (like I

Re: [Rpy] From matrices to data.frames and vice versa

2011-11-25 Thread Luca Beltrame
I've been looking through the code and I have a couple of questions on design. I wonder if - it is preferable to hack in a special case of "tlist" being a Matrix in the DataFrame constructor, e.g. if isinstance(tlist, Matrix); - it is preferable (like I suggested at first) to have a separate pa

Re: [Rpy] From matrices to data.frames and vice versa

2011-11-25 Thread Arnaldo Russo
Hi Luca! thats a good idea. If you could give feedback over yours code improvement, I'll be glad. It's a possibility with data.matrix Cheers, Arnaldo. *Arnaldo D'Amaral Pereira Granja Russo* Lab. de Estudos dos Oceanos e Clima Instituto de Oceanografia Universidade Federal do Rio Grande e-mai

Re: [Rpy] From matrices to data.frames and vice versa

2011-11-25 Thread Luca Beltrame
In data venerdì 25 novembre 2011 07:18:24, Laurent Gautier ha scritto: > The "Python way" might be to add a switch in the constructors of the > relevant classes (rpy2.robjects.vectors.Matrix and > rpy2.robjects.vectors.DataFrame). I was thinking of something like (for DataFrame): def __init__(se

Re: [Rpy] From matrices to data.frames and vice versa

2011-11-24 Thread Laurent Gautier
It could be added. The "Python way" might be to add a switch in the constructors of the relevant classes (rpy2.robjects.vectors.Matrix and rpy2.robjects.vectors.DataFrame). You could start by extending the current classes and implement a custom constructor and see how it goes for you. Bes

[Rpy] From matrices to data.frames and vice versa

2011-11-24 Thread Luca Beltrame
Hello, R uses as.data.frame and as.matrix to easily move (compatible) data structures from data.frame to matrix and vice versa. I was wondering if it would make sense to have such a feature in rpy2, at least to swap between matrix and data.frame. Currently to do so it is needed to importr("bas