您可以在Google colaboratory中使用rmagic(rpy2)吗?

时间:2018-07-21 17:18:53

标签: 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
    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没有安装在运行此笔记本的任何云计算机上,并且可能无法安装它。但我希望我做错了,可能有人知道有解决方法。

1 个答案:

答案 0 :(得分:2)

好的,我回答了我自己的问题。我以为这肯定会失败,但还是尝试了:

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

成功了!