I am trying to load several R packages like such:
%%R
# Load libraries from correct lib Paths for my environment - ignore this!
.libPaths(.libPaths()[c(3,2,1)])
# Load all the R libraries we will be using in the notebook
library(scran)
library(RColorBrewer)
library(slingshot)
library(monocle)
library(gam)
library(BiocParallel)
library(ggplot2)
library(plyr)
library(MAST)
However, I get this error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
File /opt/anaconda3/envs/tsc-env/lib/python3.9/site-packages/rpy2/rinterface_lib/conversion.py:179, in _get_cdata(obj)
178 try:
--> 179 cdata = obj.__sexp__._cdata
180 except AttributeError:
AttributeError: 'numpy.str_' object has no attribute '__sexp__'
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
Cell In[5], line 1
----> 1 get_ipython().run_cell_magic('R', '', '# Load libraries from correct lib Paths for my environment - ignore this!n .libPaths(.libPaths()[c(3,2,1)])nn# Load all the R libraries we will be using in the notebooknnlibrary(scran)nlibrary(RColorBrewer)nlibrary(slingshot)nlibrary(monocle)nlibrary(gam)nlibrary(BiocParallel)nlibrary(ggplot2)nlibrary(plyr)nlibrary(MAST)n#library(Seurat)n#library(scater)n#library(scDblFinder)n#library(sctransform)n#library(scry)n#library(clusterExperiment)n')
File /opt/anaconda3/envs/tsc-env/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2517, in InteractiveShell.run_cell_magic(self, magic_name, line, cell)
2515 with self.builtin_trap:
2516 args = (magic_arg_s, cell)
-> 2517 result = fn(*args, **kwargs)
2519 # The code below prevents the output from being displayed
2520 # when using magics with decorator @output_can_be_silenced
2521 # when the last Python token in the expression is a ';'.
2522 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):
File /opt/anaconda3/envs/tsc-env/lib/python3.9/site-packages/rpy2/ipython/rmagic.py:935, in RMagics.R(self, line, cell, local_ns)
...
182 'to map it to one: %s' % repr(obj))
183 else:
184 cdata = cls(obj)
ValueError: Not an rpy2 R object and unable to map it to one: np.str_('value')
Checking with R, I have all the packages successfully installed, but how can I fix this value error? Thank you,
New contributor
Skim is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.