简体   繁体   English

无法从R.Net引用外部R程序包

[英]Can't reference external R package from R.Net

To leverage R from my .Net website, i'm using R.Net (1.5.13). 为了利用我的.Net网站上的R,我正在使用R.Net(1.5.13)。 To some extend this is working fine for me, but when i'm trying to reference an external R package (the package: tm) i'm running into deep trouble. 从某种程度上来说,这对我来说很好用,但是当我尝试引用一个外部R包(该包:tm)时,我遇到了麻烦。

The following C# code: 以下C#代码:

REngine engine = null;
REngine.SetEnvironmentVariables();
engine = REngine.GetINstance();
engine.Initialize();

engine.Evaluate(".libPaths('C:/Users/Laptop/Documents/R/win-library/3.1')");
engine.Evaluate("library(tm)");

is resulting in: package or namespace load failed form 'tm' 导致: 程序包或名称空间加载失败,格式为“ tm”

From RStudio the command library(tm) works without any exceptions. 在RStudio中,命令库(tm)正常运行。

I tried the following steps to solve this problem: 我尝试了以下步骤来解决此问题:

  • a reinstall of R 重新安装R
  • updating packages from R studio 从R Studio更新软件包
  • adding 'C:/Users/Laptop/Documents/R/win-library/3.1' to R_LIBS, R_LIBS_USER and R_LIBS_SITE 将'C:/Users/Laptop/Documents/R/win-library/3.1'添加到R_LIBS,R_LIBS_USER和R_LIBS_SITE

But nothing seems to help so far. 但是到目前为止,似乎没有任何帮助。

Can someone help me with this nasty problem? 有人可以帮助我解决这个令人讨厌的问题吗?

Some information from sessionInfo() : 来自sessionInfo()的一些信息:

R version: 3.1.0 (2014-04-10) R版本:3.1.0(2014-04-10)

Platform: x86_64_w64_mingw32/x64 (64-bit) 平台:x86_64_w64_mingw32 / x64(64位)

other attached packages: [1] tm_0.5-10 其他随附的软件包:[1] tm_0.5-10

The last two issues logged at the codeplex site, here and here , relate to this problem: running R.NET from an IIS web app is a known long-standing issue. 在Codeplex站点( 此处此处)记录的最后两个问题与该问题有关:从IIS Web应用程序运行R.NET是一个长期存在的已知问题。 Thankfully, recently skyguy94 has done the best diagnosis and explanation of the issue to date, and as I understand proposes a workaround. 值得庆幸的是,最近skyguy94对该问题进行了迄今为止最好的诊断和解释,据我所知,他建议一种解决方法。 You should give it a try. 您应该尝试一下。

Future versions of R.NET will likely offer an easier way to, er, accomodate IIS, but this is subject to the time of already busy volunteers. 将来的R.NET版本可能会提供一种更简便的方式来适应IIS,但这取决于已经忙碌的志愿者的时间。 Meanwhile, I'll update the home page to flag the vexed issues running under IIS. 同时,我将更新主页以标记IIS下运行的烦恼问题。

There might be other base package/s that may be failing after the package shown in the error. 错误显示的包之后,可能还有其他基本包可能失败。

In my case matrixStats was failing but in the background stats was failing to load, and that was failing because it was trying to find core R dlls inside the stats library. 在我的情况下,matrixStats失败了,但是在后台stats未能加载,那是失败的,因为它试图在stats库中查找核心R dll。

I fixed the issue from another post: http://author-entry17.rssing.com/chan-9456546/all_p43.html 我从另一篇文章中解决了该问题: http : //author-entry17.rssing.com/chan-9456546/all_p43.html

You have to copy over the dlls from the architecture folder into the package path as a work around. 您必须将dll从架构文件夹复制到程序包路径中,以解决此问题。

ie copy dlls in C:\\Program Files\\R\\R-3.1.0\\bin\\i386 or C:\\Program Files\\R\\R-3.1.0\\bin\\x64 即复制C:\\ Program Files \\ R \\ R-3.1.0 \\ bin \\ i386或C:\\ Program Files \\ R \\ R-3.1.0 \\ bin \\ x64中的dll

to

R\\R-3.3.1\\library\\stats\\libs\\x64 or R\\R-3.3.1\\library\\stats\\libs\\i386 R \\ R-3.3.1 \\ library \\ stats \\ libs \\ x64或R \\ R-3.3.1 \\ library \\ stats \\ libs \\ i386

as a work around. 作为解决方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM