来自rpy2的个人库中的参考包

时间:2015-10-23 18:23:00

标签: python r rpy2

我刚刚通过RStudio将CRAN的MSwM软件包安装到我的个人库位置,我试图用rpy2从Python调用它。但是,它给了我这个错误:

void TfsCheckout(string tfsServer, string wkSpace, string fileName)
{
    try
    {
        //new method
        var pc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(tfsServer));
        var versionControlServer = (VersionControlServer)pc.GetService((typeof(VersionControlServer)));
        var workspace = versionControlServer.GetWorkspace(wkSpace);
        var result = workspace.PendEdit(fileName);

        //obsolete method
        var tfs = new TeamFoundationServer(tfsServer, new UICredentialsProvider());
        var versionControl = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
        var workspc = versionControl.GetWorkspace(Environment.MachineName, versionControl.AuthenticatedUser);
        result = workspc.PendEdit(fileName);

        UpdateStatus(new UpdateStatusEventArgs("Checkout: " + fileName));
        UpdateStatus(new UpdateStatusEventArgs("Result: " + result + " (1=success 0=fail)"));
    }
    catch (Exception ex)
    {
        UpdateStatus(new UpdateStatusEventArgs(ex.ToString()));
        UpdateStatus(new UpdateStatusEventArgs("Done"));
    }
}

我尝试过引用标准包,但加载时没有问题。这是我在Python中的代码:

rpy2.rinterface.RRuntimeError: Error in loadNamespace(name) : 
there is no package called 'MSwM'

因此, base utils 都已正确加载,但markov无法加载。任何人都可以了解如何在个人库中获取包以在rpy2中运行?(顺便说一下,我的设置是在Windows 7中) 仅仅是当前环境设置如下: R_USER = XXX R_HOME = C:\ Program Files \ R \ R-3.2.2

我的个人图书馆位于C:\ Users \ xxx \ Documents \ R \ win-library \ 3.2中,我可以加载MSwM并在RStudio中运行。

1 个答案:

答案 0 :(得分:2)

没关系。我找到了答案,因为importr有lib_loc参数来指定包的位置,所以我正在执行以下操作,现在它正在运行:

markov=importr('MSwM',lib_loc = "C:/Users/xxx/Documents/R/win-library/3.2")