2

I'm using the R.NET project in C# to call R functions. Is there a way to create a DataFrame in C#? I see there is a DataFrame type here: https://rdotnet.codeplex.com/documentation

Currently I can create a data.frame in R by manipulating my data (integer values) into a series of strings and then using R.NET's evaluate command, but is there a way where I can push my data (integer values) to R without having to go through a string conversion process?

For example (and my ultimate question is), is there a way to create a DataFrame in C# using native integer values?

Thanks in advance.

2
  • it seems it is possible: look at that Commented Oct 22, 2015 at 19:26
  • But when looking at this it seems there is no SetRow() method Commented Oct 22, 2015 at 19:42

1 Answer 1

1

The REngine object has a method CreateDataFrame, and this is the preferred way to create data frames.

You'll find example usage in the R.NET unit tests.

Another example can be found in an optimisation log extraction utility

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, @j-m. After further research, this seems to be the only way to do it through a specifically defined R.NET method. However, I found that I was able to achieve faster results by simply calling the eval method on the R.net engine and using syntax as one would use in R. So a simple example would be: myREngine.eval ("myDataframe <- data.frame (col1=c(1,2,3), col2=c(4,5,6), col3=c(7,8,9)"); ... I created a method to create the eval string given a C# DataFrame object, which, altogether, works faster than the CreateDataFrame method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.