Use rpy2 on different R version (Windows)

时间:2019-05-31 11:25:51

标签: python r rpy2

I am rather new in python, so this might be a very silly question.

I have installed multiple R version on my computer, R3.5.1 and a Microsoft RClient (which is R3.4.3). I would like to use a R package (olapR) in Python, but the problem is that package is only available in the RClient, but not in R3.5.1. When I used rpy2 in Python to try call olapR, it returns the following error:

Error: package 'olapR' was installed by an R version with different internals; it needs to be reinstalled for use with this R version

I then go on and check the R version used in Python by:

import rpy2.robjects.packages as rpackages
baseR = rpackages.importr('base')
print(baseR.R_Version())

which returns a version.string of:

$version.string

[1] "R version 3.5.1 (2018-07-02)

This leads me to think that the R version being used in Python, is R3.5.1

So my question is, how to change the R version used in Python into my desired version? I know the path of RClient which is in C:\Program Files\Microsoft\R Client\R_SERVER

0 个答案:

没有答案