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 Arun you have complained that it "takes away the names of the variables", leading me to question whether you really want what you have asked for because the "m,n,value" format has no room for the original names. (There are potential solutions to that problem, but they are outside of the scope of your original question.)
Since you apparently don't know the difference between a matrix and a data frame, I will pass on responding further to this thread until you provide a reproducible example. This is because there are several potential problems introduced by applying this algorithm to arbitrary data frames. You should (re)read the Introduction to R regarding data frames and matrices (note particularly that each column of a data frame can be of a different type), and you should read [1] paying particular attention to how small amounts of sample data can be provided in your reproducible example.
Also, please read the Posting Guide mentioned at the bottom of this email. In particular, that document requests that you NOT use HTML email format because what we see is usually not what you saw when you do that (which makes it very hard to understand what you are trying to tell us).
[1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
On Sat, Mar 1, 2014 at 12:38 AM, Jeff Newmiller <jdnew...@dcn.davis.ca.us> wrote: library(reshape2) mx <- matrix( 1:12, nrow=3 ) mxdf <- melt( mx ) names( mxdf ) <- c( "m", "n", "value" ) --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnew...@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. On February 28, 2014 5:49:26 PM PST, Chirag Gupta <cxg...@email.uark.edu> 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 and >cell >value in the original matrix. > >Any suggestions? -- Chirag Gupta Department of Crop, Soil, and Environmental Sciences, 115 Plant Sciences Building, Fayetteville, Arkansas 72701
--------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnew...@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k ---------------------------------------------------------------------------
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.