当前位置: 首页>>代码示例>>Python>>正文


Python packages.importr方法代码示例

本文整理汇总了Python中rpy2.robjects.packages.importr方法的典型用法代码示例。如果您正苦于以下问题:Python packages.importr方法的具体用法?Python packages.importr怎么用?Python packages.importr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rpy2.robjects.packages的用法示例。


在下文中一共展示了packages.importr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: install_matchit

# 需要导入模块: from rpy2.robjects import packages [as 别名]
# 或者: from rpy2.robjects.packages import importr [as 别名]
def install_matchit(self):
        from rpy2.robjects.packages import importr
        import rpy2.robjects.packages as rpackages
        from rpy2.robjects.vectors import StrVector
        import rpy2.robjects as robjects

        package_names = ["MatchIt"]

        names_to_install = [x for x in package_names if not rpackages.isinstalled(x)]
        if len(names_to_install) > 0:
            robjects.r.options(download_file_method='curl')
            utils = rpackages.importr('utils')
            utils.chooseCRANmirror(ind=0)
            utils.chooseCRANmirror(ind=0)
            utils.install_packages(StrVector(names_to_install))

        return importr("MatchIt") 
开发者ID:d909b,项目名称:perfect_match,代码行数:19,代码来源:psm.py

示例2: install_grf

# 需要导入模块: from rpy2.robjects import packages [as 别名]
# 或者: from rpy2.robjects.packages import importr [as 别名]
def install_grf(self):
        from rpy2.robjects.packages import importr
        import rpy2.robjects.packages as rpackages
        from rpy2.robjects.vectors import StrVector
        import rpy2.robjects as robjects

        robjects.r.options(download_file_method='curl')

        package_names = ["grf"]
        utils = rpackages.importr('utils')
        utils.chooseCRANmirror(ind=0)
        utils.chooseCRANmirror(ind=0)

        names_to_install = [x for x in package_names if not rpackages.isinstalled(x)]
        if len(names_to_install) > 0:
            utils.install_packages(StrVector(names_to_install))

        return importr("grf") 
开发者ID:d909b,项目名称:perfect_match,代码行数:20,代码来源:causal_forest.py

示例3: install_bart

# 需要导入模块: from rpy2.robjects import packages [as 别名]
# 或者: from rpy2.robjects.packages import importr [as 别名]
def install_bart(self):
        import rpy2.robjects.packages as rpackages
        from rpy2.robjects.packages import importr
        from rpy2.robjects.vectors import StrVector
        import rpy2.robjects as robjects

        robjects.r.options(download_file_method='curl')

        # install.packages("rJava")
        rj = importr("rJava", robject_translations={'.env': 'rj_env'})
        rj._jinit(parameters="-Xmx16g", force_init=True)
        print("rJava heap size is", np.array(rj._jcall(rj._jnew("java/lang/Runtime"), "J", "maxMemory"))[0] / 1e9,
              "GB.", file=sys.stderr)

        package_names = ["bartMachine"]
        utils = rpackages.importr('utils')
        utils.chooseCRANmirror(ind=0)
        utils.chooseCRANmirror(ind=0)

        names_to_install = [x for x in package_names if not rpackages.isinstalled(x)]
        if len(names_to_install) > 0:
            utils.install_packages(StrVector(names_to_install))

        return importr("bartMachine") 
开发者ID:d909b,项目名称:perfect_match,代码行数:26,代码来源:bart.py

示例4: pi0est

# 需要导入模块: from rpy2.robjects import packages [as 别名]
# 或者: from rpy2.robjects.packages import importr [as 别名]
def pi0est(p, lambda_qvalue=None):
    """Wrapper for qvalue::pi0est"""
    qvalue = importr("qvalue")
    rp = rpy2.robjects.vectors.FloatVector(p)
    # with suppress_stdout():
    if lambda_qvalue is None:
        pi0res = qvalue.pi0est(rp)
    else:
        if not isinstance(lambda_qvalue, Iterable):
            lambda_qvalue = [lambda_qvalue]
        rlambda = rpy2.robjects.vectors.FloatVector(lambda_qvalue)
        pi0res = qvalue.pi0est(rp, rlambda)
    pi0 = np.array(pi0res.rx2('pi0'))[0]
    pi0_lambda = np.array(pi0res.rx2('pi0.lambda'))
    lambda_vec = np.array(pi0res.rx2('lambda'))
    pi0_smooth = np.array(pi0res.rx2('pi0.smooth'))
    return pi0, pi0_lambda, lambda_vec, pi0_smooth 
开发者ID:broadinstitute,项目名称:tensorqtl,代码行数:19,代码来源:rfunc.py

示例5: importable

# 需要导入模块: from rpy2.robjects import packages [as 别名]
# 或者: from rpy2.robjects.packages import importr [as 别名]
def importable(self) -> bool:
        try:
            import rpy2.robjects.packages as rpackages

            rpackages.importr(self.package_name, robject_translations={".env": "env"})

            return True
        except Exception:
            return False 
开发者ID:ryantam626,项目名称:jupyterlab_code_formatter,代码行数:11,代码来源:formatters.py

示例6: format_code

# 需要导入模块: from rpy2.robjects import packages [as 别名]
# 或者: from rpy2.robjects.packages import importr [as 别名]
def format_code(self, code: str, notebook: bool, **options) -> str:
        import rpy2.robjects.packages as rpackages

        format_r = rpackages.importr(
            self.package_name, robject_translations={".env": "env"}
        )
        formatted_code = format_r.tidy_source(text=code, output=False, **options)
        return "\n".join(formatted_code[0]) 
开发者ID:ryantam626,项目名称:jupyterlab_code_formatter,代码行数:10,代码来源:formatters.py

示例7: installRSynth

# 需要导入模块: from rpy2.robjects import packages [as 别名]
# 或者: from rpy2.robjects.packages import importr [as 别名]
def installRSynth():
    from rpy2.robjects.packages import importr
    utils = importr('utils')
    utils.install_packages('Synth') 
开发者ID:microsoft,项目名称:SparseSC,代码行数:6,代码来源:test_simulation.py

示例8: installRCausalImpact

# 需要导入模块: from rpy2.robjects import packages [as 别名]
# 或者: from rpy2.robjects.packages import importr [as 别名]
def installRCausalImpact():
    from rpy2.robjects.packages import importr
    utils = importr('utils')
    utils.install_packages('CausalImpact') 
开发者ID:microsoft,项目名称:SparseSC,代码行数:6,代码来源:test_simulation.py

示例9: base

# 需要导入模块: from rpy2.robjects import packages [as 别名]
# 或者: from rpy2.robjects.packages import importr [as 别名]
def base():
    return importr('base') 
开发者ID:cstoeckert,项目名称:iterativeWGCNA,代码行数:4,代码来源:imports.py

示例10: wgcna

# 需要导入模块: from rpy2.robjects import packages [as 别名]
# 或者: from rpy2.robjects.packages import importr [as 别名]
def wgcna():
    return importr('WGCNA') 
开发者ID:cstoeckert,项目名称:iterativeWGCNA,代码行数:4,代码来源:imports.py

示例11: stats

# 需要导入模块: from rpy2.robjects import packages [as 别名]
# 或者: from rpy2.robjects.packages import importr [as 别名]
def stats():
    return importr('stats') 
开发者ID:cstoeckert,项目名称:iterativeWGCNA,代码行数:4,代码来源:imports.py

示例12: graphics

# 需要导入模块: from rpy2.robjects import packages [as 别名]
# 或者: from rpy2.robjects.packages import importr [as 别名]
def graphics():
    return importr('graphics') 
开发者ID:cstoeckert,项目名称:iterativeWGCNA,代码行数:4,代码来源:imports.py

示例13: grdevices

# 需要导入模块: from rpy2.robjects import packages [as 别名]
# 或者: from rpy2.robjects.packages import importr [as 别名]
def grdevices():
    return importr('grDevices') 
开发者ID:cstoeckert,项目名称:iterativeWGCNA,代码行数:4,代码来源:imports.py

示例14: qvalue

# 需要导入模块: from rpy2.robjects import packages [as 别名]
# 或者: from rpy2.robjects.packages import importr [as 别名]
def qvalue(p, lambda_qvalue=None):
    """Wrapper for qvalue::qvalue"""
    qvalue = importr("qvalue")
    rp = rpy2.robjects.vectors.FloatVector(p)
    if lambda_qvalue is None:
        q = qvalue.qvalue(rp)
    else:
        if not isinstance(lambda_qvalue, Iterable):
            lambda_qvalue = [lambda_qvalue]
        rlambda = rpy2.robjects.vectors.FloatVector(lambda_qvalue)
        q = qvalue.qvalue(rp, **{'lambda':rlambda})
    qval = np.array(q.rx2('qvalues'))
    pi0 = np.array(q.rx2('pi0'))[0]
    return qval, pi0 
开发者ID:broadinstitute,项目名称:tensorqtl,代码行数:16,代码来源:rfunc.py

示例15: fit_and_evaluate

# 需要导入模块: from rpy2.robjects import packages [as 别名]
# 或者: from rpy2.robjects.packages import importr [as 别名]
def fit_and_evaluate(x,z,t,y,df):
    '''
    Fit and evaluate non-parametric regression using  Darolles, Fan, Florens and Renault (2011)

    Implemented in the `np` package in R.

    See [the np package documation](https://cran.r-project.org/web/packages/np/np.pdf) for details.
    '''
    npr=importr('np')
    y_R = robjects.FloatVector(list(y.flatten()))
    (x_eval, t_eval), y_true = test_points(df, 10000)
    mod = npr.npregiv(y_R, t, z, x=x, zeval=t_eval, xeval=x_eval,
                    method="Tikhonov", p=0, optim_method ="BFGS")
    return ((y_true - to_array(mod.rx2('phi.eval')))**2).mean() 
开发者ID:jhartford,项目名称:DeepIV,代码行数:16,代码来源:nonpar.py


注:本文中的rpy2.robjects.packages.importr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。