I have just started to use the rdotNet from: http://rdotnet.codeplex.com/. I have never used R itself before but can do simple arithmetic in it. I have been able to create the instance and do some of the simple numeric calculations in c#. My issue is when i read in a csv file and create the dataframe. The information is all loaded correctly and I can see it when i debug.

When I try to go though the dataframe and print the contents to the screen, the 1st iteration shows me the correct information but after that it seems just to get numbers instead of the actually information.

Since i can do basic calculations in in the solution I will not write the begging code which will create the instance of the REngine. I will show is how I read the file in which i have place in the debug folder of the application: Location of Downloaded csv file I use: http://www.rqtl.org/sampledata/listeria.csv

engine.Evaluate("library(datasets)");

engine.Evaluate("dataset1 <- read.csv(file = \" listeria.csv\", header = TRUE, sep = ',')");

DataFrame dataset1 = engine.GetSymbol("dataset1").AsDataFrame();

//Here is the problem

for (int row = 0, row < dataset1.RowCount; row++)

{

     for ( int col = 0; col < dataset1.ColumnCount; k++)

     {

        Console.Writeline(dataset1[row,col])

     }

}

My question is can someone tell me if I am doing something wrong or is there another way of going through the Dataframe in RdotNet to get the information.

Hopefully i have explained everything, If you need more information, please feel free to ask.

Built in :

Visual Studio 2013, using a console Application, framework 4.5.1, RdotNet DLL: Vers 1.5.5 and in Win 7 64 Bit  
有帮助吗?

解决方案

Try setting stringsAsFactors to FALSE.

engine.Evaluate("dataset1 <- read.csv(file = 'listeria.csv', header = TRUE, sep = ',', stringsAsFactors = FALSE)");
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top