Re: [R] Retain names in conversion of matrix to vector

2007-06-18 Thread philozine
Fantastic. All of those methods worked, though I did have to first convert my matrices using the data.matrix command. Thank you for the assistance. Is there any equally simple way to re-convert the resulting table/matrix to its original NxN form? I do not see any obvious opposites to the cbind

[R] Retain names in conversion of matrix to vector

2007-06-14 Thread philozine
Hi R-listers, I'm using R only for a few basic functions but am having difficulty doing something that *should* be simple. I have an nxn matrix, Q, where Q[i,j] is a directed value (in this case, oil exports from i to j). Note that Q[i,j]~=Q[j,i]. I imported column names along with the matrix

Re: [R] Retain names in conversion of matrix to vector

2007-06-14 Thread Bill.Venables
There is a slightly surprising way to do this in one step. Here's an example tmp - matrix(1:16, 4, 4) dimnames(tmp) - list(letters[1:4], letters[1:4]) tmp a b c d a 1 5 9 13 b 2 6 10 14 c 3 7 11 15 d 4 8 12 16 as.data.frame(as.table(tmp)) Var1 Var2 Freq 1 aa1 2 ba

Re: [R] Retain names in conversion of matrix to vector

2007-06-14 Thread Charles C. Berry
I think your.df - as.data.frame( as.table( your.matrix ) ) colnames( your.df ) - c( i, j, Q ) write.table( your.df, file = your.file.name, row.names=FALSE ) will do this. Chuck On Thu, 14 Jun 2007, philozine wrote: Hi R-listers, I'm using R only for a few basic