gpt4 book ai didi

c# - 将 R 与 RdotNet 连接时显示设置环境变量 'PATH'

转载 作者:太空宇宙 更新时间:2023-11-03 15:51:50 25 4
gpt4 key购买 nike

当我运行警告

RDotNet.NativeLibrary.UnmanagedDll.SetDllDirectory(string) is obsolete Set environment variable 'PATH' instead. 

我不知道该怎么做。如何设置变量路径请快速帮助。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using RDotNet;
namespace WindowsFormsApplication7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
string dlldir = @"C:\Program Files\R\R-3.1.1\bin\x64";
REngine.SetDllDirectory(dlldir);
REngine.CreateInstance("RDotNet");

}


private void button1_Click(object sender, EventArgs e)
{

REngine engine = REngine.GetInstanceFromID("RDotNet");

try
{

// import csv file
engine.Evaluate("dataset<-read.table(file.choose(), header=TRUE, sep = ',')");

// retrieve the data frame
DataFrame dataset = engine.Evaluate("dataset").AsDataFrame();

for (int i = 0; i < dataset.ColumnCount; ++i)
{
dataGridView1.ColumnCount++;
dataGridView1.Columns[i].Name = dataset.ColumnNames[i];
}

for (int i = 0; i < dataset.RowCount; ++i)
{
dataGridView1.RowCount++;
dataGridView1.Rows[i].HeaderCell.Value = dataset.RowNames[i];

for (int k = 0; k < dataset.ColumnCount; ++k)
{
dataGridView1[k, i].Value = dataset[i,k];

}

}

}

catch
{
MessageBox.Show(@"Equation error.");
}
}
}
}

最佳答案

如果您想知道如何在 Windows 中设置或编辑环境变量,可以使用此链接:

Set Environment Variable

PATH 包含多个地址,也许您应该将您的 dlldir 地址添加到此变量。

关于c# - 将 R 与 RdotNet 连接时显示设置环境变量 'PATH',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25480961/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com