On 2012-04-04 00:57, Artur Wroblewski wrote:
> On Tue, Apr 3, 2012 at 5:12 PM, Laurent Gautier<lgaut...@gmail.com>  wrote:
>> On 2012-04-03 16:51, Dirk Eddelbuettel wrote:
>>> On 3 April 2012 at 15:31, Niek de Klein wrote:
>>> | Hi everyone,
>>> |
>>> | When I do:
>>> |
>>> | import rpy2.robjects as R
>>> | exampleDict = {'colum1':R.IntVector([1,2,3]), 
>>> 'column2':R.FloatVector([1,2]),
>>> | 'column3':R.FloatVector([1,2,3,4])}
>>> | R.DataFrame(exampleDict)
>>> |
>>> | I get the error that the rows are not of the same lenghts:  "arguments 
>>> imply
>>> | differing number of rows: 2, 4, 3".
>>> |
>>> | How I solved it before is to loop through the lists before making them 
>>> vectors
>>> | and adding NA to all the lists that are smaller than the longest until 
>>> they are
>>> | all of the same length. Is there an easy way of making a dataframe with 
>>> rpy2
>>> | with different column lengths?
>>>
>>> No, R imposes equal length of all vectors with a data.frame.
>>>
>>> Dirk
>>>
>> Being R, there is (of course) a catch: except with vectors of length 1.
>>
>>   >  data.frame(x=1:3, y=1)
>>    x y
>> 1 1 1
>> 2 2 1
>> 3 3 1
> Well, it is bit more tricky :)
>
>> data.frame(x=c(1,2), y=c(1,2,3,4))
>    x y
> 1 1 1
> 2 2 2
> 3 1 3
> 4 2 4

So the rule would be "when instantiating a data.frame vectors should be 
of the same length and or the shortest lengths be a multiple of the 
length of the longer ones, except for the vectors of length one".
Someone wrote a manuscript called "R inferno" for a good reason ;-)

>
> Regards,
>
> w
>
> ------------------------------------------------------------------------------
> Better than sec? Nothing is better than sec when it comes to
> monitoring Big Data applications. Try Boundary one-second
> resolution app monitoring today. Free.
> http://p.sf.net/sfu/Boundary-dev2dev
> _______________________________________________
> rpy-list mailing list
> rpy-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rpy-list


------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to