What if one wants to apply a functon i.e. to each row of a matrix, but also wants to use as an argument for this function the number of that row. As an example,
apply
cbind()ing the row numbers seems a pretty straightforward approach. For a matrix (or a data frame) the following should work:
cbind()
apply( cbind(1:(dim(test)[1]), test), 1, function(x) plot(x[-1], main=x[1]) )
or whatever you want to plot.