Hi Carson,
The following code worked to me:
import rpy2.robjects as ro
d_str = dict(x = ro.StrVector(["abc", "def", "ghi"]), y =
ro.StrVector(["yes", "no", "maybe"]))
dataf_str = ro.r['data.frame'](**d_str)
print dataf_str
Cheers
2008/12/14 Carson J.Q. Farmer
> Hi list,
>
> I'm wondering if
Hi list,
I'm wondering if anyone can tell me how to convert a dictionary of lists
of strings, into an R data.frame using rpy2. I've seen lots of talk
about converting lists of numeric values to data.frames using arrays,
but I can't seem to get anything to work for strings.
For example, the fol
>> I have a list-of-lists that I want to convert to an R dataframe. (In R, it
>> should end up as 306 rows by 12 columns.) The rpy2 instructions suggested
>> in this forum were basically: (1) convert my list of lists to a list of
>> array.array()s, (2) convert each array.array() to an RVector,
Actually, I hadn't. But trying it gave me the same "raveled" result:
>>> len(dl)
12
>>> map(len,dl)
[306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306]
>>> x=ro.r['data.frame'](dl)
>>> len(x)
3672
>>>
On Sat, 13 Dec 2008, Marcos Silva wrote:
> Well, I don't know RPy nor Python enought
Revision: 717
http://rpy.svn.sourceforge.net/rpy/?rev=717&view=rev
Author: lgautier
Date: 2008-12-14 12:35:42 + (Sun, 14 Dec 2008)
Log Message:
---
- version is now 2.0.x-dev
- minor editing in the doc
Modified Paths:
--
rpy2/branches/version_2.0.x/doc/