I am trying to transfer data from SQL to C #, then to an R server for data analysis, then back to my web application; however, the COM interface that I use does not allow the transfer of complex data types between C # and R (there are no data tables). I got it to work in the past using the following code:
int count = dataTable.Rows.Count;
object[] y = new object[count];
object[] x = new object[count];
for (int i = 0; i < count; i++)
{
y[i] = Convert.ToDouble(dataTable.Rows[i][0]);
x[i] = Convert.ToDouble(dataTable.Rows[i][1]);
}
StatConnector r = new STATCONNECTORSRVLib.StatConnectorClass();
r.Init("R");
r.SetSymbol("y", y);
r.SetSymbol("x", x);
Now my problem arises from the fact that I'm no longer limited to just doubling, all that comes out of the SQL database is fair play (int, varchar, etc.), and that I no longer call only two data columns (this may, however, be indicated by many users).
How to convert data of dynamic sizes and dynamic data types into an array that can be safely transferred to rcom?