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?
edit: I tried
myparams = {'na.rm': True}
R.DataFrame(exampleDict, **myparams)
but R.DataFrame only accepts one argument.
As Igautier said, it was answered on the rpy mailing-list. It can’t be done. So I keep to my workaround of adding NA_Reals and NA_Ints to the vectors that are smaller than the largest vector before making a dataframe.