0

The R code mentioned below is using a library CALIBERdrugdose and is returning a dataframe by using fuction doseconverter. We need to call this r script or rfunc(x) in python how we can do that?

library(CALIBERdrugdose)
rfunc <- function(x){
l=doseconvert(c(x))
return(l)
}

when i tried to run it this way

robjects.r('''
    # create a function `f`
    library(CALIBERdrugdose)
   rfunc <- function(x){
   l=doseconvert(c(x))
  return(l)
    }
    # call the function `f` with argument value 3
    rfunc("sadas")
    ''')

it was giving me this error..

  RRuntimeError                             Traceback (most recent call last)
<ipython-input-89-5aea02cf4722> in <module>()
     10         # call the function `f` with argument value 3
     11         rfunc("sadas")
---> 12         ''')

D:\workspace\lib\site-packages\rpy2\robjects\__init__.py in __call__(self, string)
    350     def __call__(self, string):
    351         p = _rparse(text=StrSexpVector((string,)))
--> 352         res = self.eval(p)
    353         return conversion.ri2py(res)
    354 

D:\workspace\lib\site-packages\rpy2\robjects\functions.py in __call__(self, *args, **kwargs)
    176                 v = kwargs.pop(k)
    177                 kwargs[r_k] = v
--> 178         return super(SignatureTranslatedFunction, self).__call__(*args, **kwargs)
    179 
    180 pattern_link = re.compile(r'\\link\{(.+?)\}')

D:\workspace\lib\site-packages\rpy2\robjects\functions.py in __call__(self, *args, **kwargs)
    104         for k, v in kwargs.items():
    105             new_kwargs[k] = conversion.py2ri(v)
--> 106         res = super(Function, self).__call__(*new_args, **new_kwargs)
    107         res = conversion.ri2ro(res)
    108         return res

RRuntimeError: Error in library(CALIBERdrugdose) : 
  there is no package called 'CALIBERdrugdose'

1 Answer 1

1

The error message returned by R is pointing out the absence of the package you would like to use, or rather the inability of R to find it in order to load it.

Sign up to request clarification or add additional context in comments.

3 Comments

If you're sure that you have that package installed properly (check it out in R directly), then the most likely problem is that python is using a different installation of R than the one you intended.
How to check which installation of R python is using ?
run sessionInfo() in your python's R implementation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.