private void CreateTableRowColumnHeadersOld(string objectName, XmlNode thisNode, string classtype = "")
{
//Creating row col headers if any present on R side object.
string[] strcolheaders = null;
string[] strrowheaders = null;
int srdim = 1, scdim = 1;//array with at least 1 row 1 col
if (!this._RServer.Evaluate("is.na(ncol(" + objectName + "))").AsLogical()[0]) // if no. of col does exists
{
scdim = this._RServer.Evaluate("ncol(" + objectName + ")").AsInteger()[0];
if (!this._RServer.Evaluate("is.null(colnames(" + objectName + "))").AsLogical()[0])
{
CharacterVector cv = this._RServer.Evaluate("colnames(" + objectName + ")").AsCharacter();
int siz = cv.Count();
strcolheaders = new string[siz];
for (int ic = 0; ic < siz; ic++)
{
strcolheaders[ic] = cv[ic];
}
}
}
if (!this._RServer.Evaluate("is.na(nrow(" + objectName + "))").AsLogical()[0]) // if no. of row does exists
{
srdim = this._RServer.Evaluate("nrow(" + objectName + ")").AsInteger()[0];
if (!this._RServer.Evaluate("is.null(rownames(" + objectName + "))").AsLogical()[0])
{
CharacterVector cv = this._RServer.Evaluate("rownames(" + objectName + ")").AsCharacter();
int siz = cv.Count();
strrowheaders = new string[siz];
for (int ic = 0; ic < siz; ic++)
{
strrowheaders[ic] = cv[ic];
}
}
}
//this section for int16[,], in32[,], int64[,]. Check if this is needed for these Ints and other types too.
// This happens with R 'table' having single row ( and multi col )
// When in R console you print R 'table' column names are shown. But when you try to find out colnames(table)
// its subscript out of bounds. Instead, rownames(table) gives the column name. Which is weird.
if (srdim > 1 && scdim == 1 && classtype.Equals("table")) //changing row headers to col headers.Awkward but 1D 'table' need this.
{
strcolheaders = strrowheaders;
strrowheaders = null;
}
//01May2014 table header
XmlElement strtableheader = thisNode.OwnerDocument.CreateElement("tableheader");
if (tableheader != null && tableheader.Length > 0)
strtableheader.InnerText = tableheader;//Table header assigned
thisNode.AppendChild(strtableheader);
//Col Row Headers
XmlElement strcolnames = thisNode.OwnerDocument.CreateElement("colheaders");
if (strcolheaders != null)
strcolnames.InnerText = string.Join(",", strcolheaders);//Array to comma separated string
XmlElement strrownames = thisNode.OwnerDocument.CreateElement("rowheaders");
if (strrowheaders != null)
strrownames.InnerText = string.Join(",", strrowheaders);//Array to comma separated string
thisNode.AppendChild(strcolnames);
thisNode.AppendChild(strrownames);
}