Google colaboratory 你能在谷歌协作实验室中使用rmagic(rpy2)吗?

Google colaboratory 你能在谷歌协作实验室中使用rmagic(rpy2)吗?,google-colaboratory,Google Colaboratory,我知道google colaboratory还不支持R内核。那rmagic呢?我可以使用rpy2吗 我试过: !pip install rpy2==2.8.6 得到: Collecting rpy2==2.8.6 Using cached https://files.pythonhosted.org/packages/32/54/d102eec14f9cabd0df60682a38bd45c36169a1ec8fb8a690bf436cb6d758/rpy2-2.8.6.tar.gz

我知道google colaboratory还不支持R内核。那rmagic呢?我可以使用rpy2吗

我试过:

!pip install rpy2==2.8.6
得到:

Collecting rpy2==2.8.6
  Using cached https://files.pythonhosted.org/packages/32/54/d102eec14f9cabd0df60682a38bd45c36169a1ec8fb8a690bf436cb6d758/rpy2-2.8.6.tar.gz
    Complete output from command python setup.py egg_info:
    Error: Tried to guess R's HOME but no command 'R' in the PATH.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-3bSiiD/rpy2/

我猜它不起作用是因为R没有安装在这个笔记本运行的任何云计算机上,而且可能无法安装它。但我希望我错了,有人可能知道一个解决办法。

好的,我回答了我自己的问题。我确信这会失败,但还是尝试了:

!apt-get update
!apt-get install r-base
!pip install rpy2==2.8.6

成功了

如果您现在想使用rpy2,我建议您使用最新版本(在撰写本文时为2.9.4)。谢谢,@lgautier。我相信rpy2中除了2.9.x之外,只支持python 3。我需要Python2.7,但对于其他使用Python3的人来说,这是一个很好的提示。@kmartin您可以添加一些示例代码来说明如何继续使用rpy2吗?例如,您是否执行了%load_ext rpy2.ipython?(现在对我不起作用)谢谢!