I need to get the row and column name of the smallest element of a matrix
> mat = matrix(data=runif(12), nrow = 4, ncol=4)
> rownames(mat) = colnames(m
> inds = which(mat == min(mat), arr.ind=TRUE)
> inds
row col
a 1 2
> rnames = rownames(mat)[inds[,1]]
> cnames = colnames(mat)[inds[,2]]
This will give you the row/column names for each entry that equals the minimum value; if you just want the first one, you could only check inds[1,1] and inds[1,2].