将数据从 python 块传递到 Rnotebook 中的 R 环境
Passing data from python chunk to R environment in 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 块可能会发生类似的事情。
我认为对于 python/R 交互,您必须将数据以一个块的形式保存到文件系统,然后在另一个块中读回。
http://rmarkdown.rstudio.com/authoring_knitr_engines.html#python
我在 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 块可能会发生类似的事情。
我认为对于 python/R 交互,您必须将数据以一个块的形式保存到文件系统,然后在另一个块中读回。
http://rmarkdown.rstudio.com/authoring_knitr_engines.html#python