Skip to content
Prev 41997 / 398500 Next

Accessing row and col names of SEXP objects

/* "GetRowNames" and "GetColNames" are utility routines which
 * locate and return the row names and column names from the
 * dimnames attribute of a matrix.  They are useful because

You have not applied them to the dimnames attribute.  Extracting 
dimnames attributes _is_ covered in R-exts:

SEXP dimnames=getAttrib(ts, R_DimNamesSymbol), 
     colnames = VECTOR_ELT(dimnames, 1);

for (j = 0; j < length(colnames); j++) 
   printf("%s\n",CHAR(STRING_ELT(colnames, j)));

looks about right, although you should do something if the colnames or 
dimnames are NULL.
On Wed, 17 Dec 2003, Whit Armstrong wrote: