Quantcast
Channel: R.NET
Viewing all articles
Browse latest Browse all 1634

New Post: Returning a time series to .net using r packages xts or zoo.

$
0
0
My modification of your sample code looks like this:
static void Main(string[] args)
{
    var rEngine = REngine.GetInstance();
    const string command = "library(xts); IndexValues <- xts(rnorm(10), Sys.Date()+1:10)";
    var df = rEngine.Evaluate(command).AsDataFrame();
}
You are correct, RDotNet is returning null. The issue is that IndexValues is an 'xts' object and is not a dataframe. I assume that you expected RDotNet to coerce the type for you in the same way 'as.data.frame()' would, but it does not.

As currently implemented, RDotNet's .AsDataFrame() exists to let the C# representation of the "IndexValues" object know that it is a C# DataFrame if and only if its already a R DataFrame.

You can see that for yourself here: https://github.com/jmp75/rdotnet/blob/2d54edfb68b98f81da70aeb450e5bdffcdc055c7/R.NET/SymbolicExpressionExtension.cs#L79

As is, I don't see a simple way to coerce a type to a dataframe from the C API, so your best bet is to call 'as.data.frame' from the R code.

Viewing all articles
Browse latest Browse all 1634

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>