public bool SendTable2RmatrixNumeric(string varName, DataTable mDtable) { var mRarrySend = DataTable2Rarray(mDtable); if (mRarrySend.matrix != null) { try { _rdn.SetSymbolNumberMatrix("X", mRarrySend.matrix); _rcmd = varName + "<- getmatrix(X)"; _rdn.EvaluateNoReturn(_rcmd); _rdn.SetSymbolCharVector("colH", mRarrySend.colHeaders); _rdn.SetSymbolCharVector("rowN", mRarrySend.rowNames); _rcmd = "colnames(" + varName + ") <- colH"; _rdn.EvaluateNoReturn(_rcmd); _rcmd = "rownames(" + varName + ") <- rowN"; _rdn.EvaluateNoReturn(_rcmd); //rcmd = varName + "<- cleanmatrix(" + varName + ")"; // here's where the duplicates are removed //rdcom.EvaluateNoReturn(rcmd); return(true); } catch (Exception e) { var errmsg = _rcmd + " " + e.Message; Console.WriteLine(errmsg); Message = e.Message; return(false); } } else { return(false); } }
/// <summary> /// Store the data table in R; duplicate rows are removed /// </summary> /// <param name="varName"></param> /// <param name="mDtable"></param> /// <returns>True if success, otherwise false</returns> public bool SendTable2RmatrixNumeric(string varName, DataTable mDtable) { clsRarray rArray; try { rArray = DataTable2Rarray(mDtable, varName); } catch (Exception e) { var errmsg = string.Format("Error converting {0} using DataTable2Rarray: {1} ", varName, e.Message); Console.WriteLine(errmsg); Message = e.Message; return(false); } if (rArray.matrix != null) { try { _rdn.SetSymbolNumberMatrix("X", rArray.matrix); _rcmd = varName + "<- getmatrix(X)"; _rdn.EvaluateNoReturn(_rcmd); _rdn.SetSymbolCharVector("colH", rArray.colHeaders); _rdn.SetSymbolCharVector("rowN", rArray.rowNames); _rcmd = "colnames(" + varName + ") <- colH"; _rdn.EvaluateNoReturn(_rcmd); _rcmd = "rownames(" + varName + ") <- rowN"; _rdn.EvaluateNoReturn(_rcmd); //rcmd = varName + "<- cleanmatrix(" + varName + ")"; // here's where the duplicates are removed //rdcom.EvaluateNoReturn(rcmd); return(true); } catch (Exception e) { var errmsg = _rcmd + " " + e.Message; Console.WriteLine(errmsg); Message = e.Message; return(false); } } return(false); }