我想將一些<class 'rpy2.robjects.vectors.Matrix'>
變量轉換成Pandas數據框。pandas.rpy.common.load_data()用法/文檔?
有很多的如何這樣做在互聯網上,所有給予簡單的例子複製粘貼的說明:
pandas.rpy.common.load_data("infert")
,而不在哪裏"infert"
是來自任何信息。 我無法得到任何類型的文檔,對這個功能(爲什麼有沒有?),但顯然我不能用它:
summary= r.summary(linear_model)
filtered_summary=summary.rx2("tTable")
print com.load_data("filtered_summary")
給我:
---------------------------------------------------------------------------
LookupError Traceback (most recent call last)
<ipython-input-68-a087eddd5220> in <module>()
8 #print test1_sum.names
9 print type(r_res)
---> 10 print com.load_data("filtered_summary")
11 #print pd.DataFrame(test1_sum.rx2("tTable"))
12
/usr/lib64/python2.7/site-packages/pandas/rpy/common.pyc in load_data(name, package, convert)
29 r.data(name)
30
---> 31 robj = r[name]
32
33 if convert:
/usr/lib64/python2.7/site-packages/rpy2/robjects/__init__.pyc in __getitem__(self, item)
226
227 def __getitem__(self, item):
--> 228 res = _globalenv.get(item)
229 res = conversion.ri2ro(res)
230 res.__rname__ = item
LookupError: 'filtered_summary' not found
同時:
summary= r.summary(linear_model)
print com.load_data("summary")
給我:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-69-b51722281aa4> in <module>()
8 #print test1_sum.names
9 print type(r_res)
---> 10 print com.load_data("summary")
11 #print pd.DataFrame(test1_sum.rx2("tTable"))
12
/usr/lib64/python2.7/site-packages/pandas/rpy/common.pyc in load_data(name, package, convert)
32
33 if convert:
---> 34 return convert_robj(robj)
35 else:
36 return robj
/usr/lib64/python2.7/site-packages/pandas/rpy/common.pyc in convert_robj(obj, use_pandas)
222 return converter(obj)
223
--> 224 raise TypeError('Do not know what to do with %s object' % type(obj))
225
226
TypeError: Do not know what to do with <class 'rpy2.robjects.functions.SignatureTranslatedFunction'> object
所以:
- 如何使用
load_data
正確 - 我怎樣才能最好的讓我的R矩陣轉換爲數據幀熊貓?