there is no package called ‘dtw’

402 Views Asked by At

I am using Google colab, I am trying to use an r package via rpy2 but it gives me an error, how can I add this pakage to rpy2 in Google colab. this is my code.

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')

The error:

 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
1

There are 1 best solutions below

0
On

From dtw's github page:

To install the latest stable version of the package, issue the following command in the R console:

install.packages("dtw")