My modification of your sample code looks like this:
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.
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.