Skip to content

sort a data matrix by all the values and keep the names

2 messages · Steven McKinney, Hadley Wickham

#
Is something missing in the melt()?
Loading required package: reshape
Error in if (!missing(id.var) && !(id.var %in% varnames)) { : 
  missing value where TRUE/FALSE needed
Error: object "dfm" not found
x1 x2 x3
1  1  4  8
2  7  6  2
Error in if (!missing(id.var) && !(id.var %in% varnames)) { : 
  missing value where TRUE/FALSE needed
Steve McKinney


-----Original Message-----
From: r-help-bounces at r-project.org on behalf of hadley wickham
Sent: Mon 9/22/2008 5:47 PM
To: zhihuali
Cc: r-help at stat.math.ethz.ch
Subject: Re: [R] sort a data matrix by all the values and keep the names
On Mon, Sep 22, 2008 at 6:54 PM, zhihuali <lzhtom at hotmail.com> wrote:
Here's one way:

dfm <- melt(x, id = c())
dfm[order(dfm$value), ]

Hadley
#
Hmm, maybe it only works in my development version (to be released v. v. soon)

Hadley
On Mon, Sep 22, 2008 at 8:02 PM, Steven McKinney <smckinney at bccrc.ca> wrote: