使用rpy2
,我想检查是否安装了给定的包。如果是,我导入它。如果没有,我先安装它。
如何检查它是否已安装?
from rpy2 import *
if not *my package is installed*:
rpy2.interactive as r
r.importr("utils")
package_name = "my_package"
r.packages.utils.install_packages(package_name)
myPackage = importr("my_package")