简体   繁体   English

R.NET中的错误“错误:未为'arch = i386'安装软件包'RMySQL'”

[英]Error in R.NET “Error: package 'RMySQL' is not installed for 'arch = i386' ”

When I am running an Rscript using the C# code I got the error that I mentioned in subject. 当我使用C#代码运行Rscript时,出现了我在主题中提到的错误。 Actually the RMySQL package is correctly installed in my system (Windows 7 64 bit)and I am able to run the script from Rconsole directly. 实际上,RMySQL软件包已正确安装在我的系统(Windows 7 64位)中,并且能够直接从Rconsole运行脚本。 But when calling from C# code I am getting this error. 但是,当从C#代码调用时,出现此错误。 Please help me to find a solution for the same. 请帮助我找到相同的解决方案。 Thank you 谢谢

This is my C# code 这是我的C#代码

  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using RDotNet;

  namespace hottopics_new
  {
   public partial class hottopic : System.Web.UI.Page
   {
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        REngine.SetEnvironmentVariables();
        REngine engine = REngine.GetInstance();
        engine.Initialize();
        var hottopic = engine.Evaluate("source('E:/******/******/Rscript/hottopics.R')").AsDataFrame();
        var words = hottopic[1].AsCharacter().ToArray();
        var freq = hottopic[2].AsCharacter().ToArray();
        Console.WriteLine(words);
        Console.WriteLine(freq);
        engine.Dispose();
    }
  }
 }

``` ```

I am getting the error in the following place in above code "var hottopic = engine.Evaluate("source('E:/ ** / ** /R script/hottopics.R')").AsDataFrame();" 我在上面的代码“ var hottopic = engine.Evaluate(“ source('E:/ ** / ** / R script / hottopics.R')”)。AsDataFrame();中的以下位置收到错误。

And this is my R script 这是我的R脚本

user_id = 39988 library(RMySQL) con = dbConnect(MySQL(), user='****', password='****', dbname='****', host='*********') # Add the text mining library for using the removeWords and stopwords functions library(tm) setwd("E:/*****/****/R script") sqlQuery <- paste("SELECT b.user_id,a.user_social_account_id,a.content FROM mydb.updates a INNER JOIN mydb.user_social_accounts b ON a.user_social_account_id = b.id WHERE a.user_social_account_id IN (SELECT id FROM mydb.user_social_accounts WHERE user_id =",user_id,')',sep = "") updates <- dbGetQuery(con,statement=sqlQuery) dbDisconnect(con) words <- read.csv("stopwords.csv",colClasses = "character") # Convert the 'words' object from data.frame to charcter vector format words <- words$Words updates$content <- tolower(updates$content) content <- updates$content # Split each words in the content and saved in a character vector format content <-unlist(strsplit(content, split=" ")) # Remove all the stopwords,numbers and symbols from it content <- removeWords(content,c(stopwords("english"),stopwords("SMART"),words)) content <- gsub("[^a-zA-Z]", "", content) # Count each words frequency using the 'table' function and store the result in data.frame format word_count <- as.data.frame(table(content)) names(word_count) <- c("Word","Freq") # Removing the blank character from the result that comes when removing the symbols and numbers word_count <- word_count[-(word_count$Word == ""),] # Order the word_count data frame in the descending order of Frequency of words word_count <- word_count[order(-word_count$Freq,word_count$Word),] head(word_count,10)

This is likely to be the known issue due to the way IIS handles environment variables . 由于IIS处理环境变量的方式,这可能是已知问题 The issue linked to has a workaround kindly proposed by the reporter of that issue. 与关联的问题具有由该问题的报告者建议的解决方法。

Please mark this as answered if the workaround solves this issue; 如果解决方法可以解决此问题,请标记为已回答; questions with ASP.NET + R.NET are a recurrent theme. ASP.NET + R.NET的问题是经常出现的主题。

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

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