[R] numeric index of a matrix column name ?
vincent@7d4.com
vincent at 7d4.com
Fri Oct 28 16:50:19 CEST 2005
Dear All,
I have written the following small code in order to return
the numeric index of a given matrix column ascii name.
It works, but there is perhaps/probably a predefined function
which does that ?
If yes, thanks for pointing me to it.
# input : a matrix M and a column ascii name
# output : the numeric index of the column
colnameindex = function(M , colname0)
{
colsnames = names(M[1,]);
theindex = which(colsnames==colname0);
return(theindex);
}
Thanks
Vincent
More information about the R-help
mailing list