I have a matrix in which each row vector has a name. I would like to check row membership in my matrix, that is I would like to turn the following into R code:
if(mat contains "rowname")
{ do appropriate task ....}
else if(mat contains "otherrowname")
{ do appropriate task ....}
else
{ do different task....}
All help is appreciated!
It is fairly common to see code that looks like:
if( sum( rowNameToFind %in% rownames(mat)) ) { TRUE }else{ FALSE }
This deals simultaneously with the rownames-missing-entirely possibility at the same time as target-not-in-rownames.