我正在使用Google colab,我试图通过rpy2使用r包,但它给我一个错误,如何在Google colab中将此包装添加到rpy2中。 这是我的代码。
import numpy as np
import rpy2.robjects.numpy2ri
rpy2.robjects.numpy2ri.activate()
from rpy2.robjects.packages import importr
import rpy2.robjects as robj
R = rpy2.robjects.r
DTW = importr('dtw')
错误:
R[write to console]: Error in loadNamespace(name) : there is no package called ‘dtw’
Calls: <Anonymous> ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
---------------------------------------------------------------------------
RRuntimeError Traceback (most recent call last)
<ipython-input-272-15b6cecae626> in <module>()
6
7 R = rpy2.robjects.r
----> 8 DTW = importr('dtw')
2 frames
/usr/local/lib/python3.6/dist-packages/rpy2/rinterface.py in __call__(self, *args, **kwargs)
787 error_occured))
788 if error_occured[0]:
--> 789 raise embedded.RRuntimeError(_rinterface._geterrmessage())
790 return res
791
RRuntimeError: Error in loadNamespace(name) : there is no package called ‘dtw’
Calls: <Anonymous> ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart