Hoping there\'s a simple answer here but I can\'t find it anywhere.
I have a numeric matrix with labelled rows and columns:
1 2 3 4
a 6
Assuming 'm' is your matrix...
data.frame(col = rep(colnames(m), each = nrow(m)),
row = rep(rownames(m), ncol(m)),
value = as.vector(m))
This executes extremely fast on a large matrix and also shows you a bit about how a matrix is made, how to access things in it, and how to construct your own vectors.