我正在嘗試Rpy2並感覺非常困難。我在我的熊貓數據幀過去了,跑了使用RPy2將lme4 ranef輸出轉換爲數據幀
m_rt = lme4.lmer(formula,verbose=True)
out = r.ranef(m_rt)
混合效應模型如果我打印出來,它看起來如預期:
$cat
(Intercept) gen delta
x 0.093546331 -0.168458284 0.144213098
y -0.082592717 0.148733010 -0.127326764
z 0.005229467 -0.009417228 0.008061863
現在我想通過這些信息反饋到大熊貓數據幀。或者真的,我可以使用任何python對象!我試圖pandas2ri.ri2py(out)
並獲得
<ListVector - Python:0x118b53248/R:0x7fe3663a3238>
[DataFrame]
<ListVector - Python:0x118b53248/R:0x7fe3663a3238>
[DataFrame]
和r.data.frame(out)
,得到了AttributeError: 'SignatureTranslatedFunction' object has no attribute 'frame'
。由於與熊貓數據框架定義有衝突,我無法安裝dplyr - 也許這就是原因。這是正常的嗎?下面的錯誤:
LibraryError: Conflict when converting R symbols in the package "dplyr" to Python symbols:
-obj_type_data_frame -> obj_type.data_frame, obj_type.data.frame
To turn this exception into a simple warning use the parameter `on_conflict="warn"\`
任何幫助非常感謝!謝謝!
數據框被包裹在一個列表中。 –
你有什麼版本的rpy2? 'import rpy2;打印(rpy2 .__版本__)' – lgautier
我有版本2.7.8 – Erin