Hi! I’m trying to use R within a Python notebook in datalore. I’m using the library rpy2 and r-essentials to run some R code and treat the results using python code. My problem is that, I’m supposed to have installed the library lme4 but, when I import it within the R code snippet, it can not be found.
The steps I have done are the following:
1.Install rpy2 and r-essentials using the packages of datalore. Furthermore I have installed cmake and pymer4 just in case these packages make it to work.
- Import Python libraries to use R
import rpy2.robjects from rpy2.robjects.packages import importr utils = importr('utils') utils.chooseCRANmirror(ind=1) utils.install_packages("nloptr") utils.install_packages("stats") utils.install_packages('lme4') %load_ext rpy2.ipython
And then I try to use the R code using run magic cell method:
get_ipython().run_cell_magic( "R", "-i df -o output", """ library(lme4) """ )
This returns an error that I’m not sure how to solve it:
Error in library(lme4) : there is no package called ‘lme4’
Does anyone faced this error too?
Thank in advance