簡體   English   中英

R.NET中的錯誤“錯誤:未為'arch = i386'安裝軟件包'RMySQL'”

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

當我使用C#代碼運行Rscript時,出現了我在主題中提到的錯誤。 實際上,RMySQL軟件包已正確安裝在我的系統(Windows 7 64位)中,並且能夠直接從Rconsole運行腳本。 但是,當從C#代碼調用時,出現此錯誤。 請幫助我找到相同的解決方案。 謝謝

這是我的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();
    }
  }
 }

```

我在上面的代碼“ var hottopic = engine.Evaluate(“ source('E:/ ** / ** / R script / hottopics.R')”)。AsDataFrame();中的以下位置收到錯誤。

這是我的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)

由於IIS處理環境變量的方式,這可能是已知問題 與關聯的問題具有由該問題的報告者建議的解決方法。

如果解決方法可以解決此問題,請標記為已回答; ASP.NET + R.NET的問題是經常出現的主題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM