你能在 google colaboratory 中使用 rmagic (rpy2) 吗?

Can you use rmagic (rpy2) in google colaboratory?

我知道 google colaboratory 尚不支持 R 内核。魔法呢?我可以使用 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

成功了!