當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。