Re: [R] reshape non-square matrix

2014-03-04 Thread Jeff Newmiller
On Tue, 4 Mar 2014, Chirag Gupta wrote: Jeff This works fine for smaller ones but I have a big dataframe. Its ~35000 X 30. When I try this command, it says "Using  as id variables". Thank you. You asked for a solution regarding a matrix. Now you talk about data frames. And in responding to

Re: [R] reshape non-square matrix

2014-03-04 Thread Chirag Gupta
Jeff This works fine for smaller ones but I have a big dataframe. Its ~35000 X 30. When I try this command, it says "Using as id variables". Thank you. On Sat, Mar 1, 2014 at 12:38 AM, Jeff Newmiller wrote: > library(reshape2) > mx <- matrix( 1:12, nrow=3 ) > mxdf <- melt( mx ) > names( mxdf

Re: [R] reshape non-square matrix

2014-03-04 Thread arun
Hi, You didn't provide any reproducible example to start with. Using Jeff's example mx <- matrix( 1:12, nrow=3 ) dimnames(mx) <- list(1:nrow(mx),1:ncol(mx)) ## setNames(as.data.frame.table(mx),c("m","n","value"))   m n value 1  1 1 1 2  2 1 2 3  3 1 3 4  1 2 4 5  2 2 5 6 

Re: [R] reshape non-square matrix

2014-03-04 Thread Chirag Gupta
This takes away names of all the variables On Sat, Mar 1, 2014 at 9:30 AM, arun wrote: > > > Hi, > You could try: > #If mat1 is the matrix > dimnames(mat1) <- list(1:nrow(mat1),1:ncol(mat1)) > setNames(as.data.frame.table(mat1),c("m","n","value")) > A.K. > > > On Friday, February 28, 2014 11:40

Re: [R] reshape non-square matrix

2014-03-01 Thread arun
Hi, You could try: #If mat1 is the matrix dimnames(mat1) <- list(1:nrow(mat1),1:ncol(mat1)) setNames(as.data.frame.table(mat1),c("m","n","value")) A.K. On Friday, February 28, 2014 11:40 PM, Chirag Gupta wrote: Hi list I have a matrix of size m x n (m and n are different, hence non square!)

Re: [R] reshape non-square matrix

2014-02-28 Thread Jeff Newmiller
library(reshape2) mx <- matrix( 1:12, nrow=3 ) mxdf <- melt( mx ) names( mxdf ) <- c( "m", "n", "value" ) --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. L

Re: [R] reshape non-square matrix

2014-02-28 Thread Rolf Turner
On 01/03/14 14:49, Chirag Gupta wrote: Hi list I have a matrix of size m x n (m and n are different, hence non square!) I want to melt it in such a way that I get a df of 3 columns. m ,n Surely you mean i, j (i = 1, ..., m), j = 1, ..., n). and cell value in the original matrix. Yes: