在Rnotebook中将数据从python块传递到R环境

时间:2017-10-02 19:16:43

标签: python r rstudio rnotebook

我在python搁置文件中给了我一些数据,我想将它传递给R进行绘图。我提取它的代码如下所示:

尝试通过单击块中的运行按钮或将光标置于其中并按 Ctrl + Shift + Enter 来执行此块。

```{python}
import numpy as np
from numpy import ma, array
import shelve

MODEL = "May2016"
d = shelve.open('fits_shelve_' + MODEL)
hilldata = d['hilldata']
allchi  = d['allchi']
aa      = d['aa'] 
rr      = d['rr'] 
names   = d['names']
weight  = d['weight']
weightc = d['weightc']
dl      = d['dl']
vi      = d['activatorM']
activatorM = d['activatorM']
activatorR = d['activatorR']
d.close()

```

我现在想将这些对象传递给R.有没有办法在Rnotebook中执行此操作?我知道SQL块可能有类似的东西。

1 个答案:

答案 0 :(得分:1)

我认为对于python / R交互,你必须将数据保存在一个块中的文件系统中,然后在另一个块中读回。

http://rmarkdown.rstudio.com/authoring_knitr_engines.html#python