Skip to content

error in my previous message

3 messages · Mark Leeds, cruz, Henrik Bengtsson

#
i'm sorry. i had an error in my previous code because i left out a 
letter in the rownames.
while fixing that, i also found a solution. so i'm sorry for the 
confusion.

below is my fix.

temp2 <- matrix(rnorm(10),nc=1,nrow=10)
rownames(temp2) <- c("a","b","c","d","e","f","g","h","i","j")
print(temp2)
temp2 <- as.matrix(temp2[order(temp2[,1,drop=FALSE]),])
print(temp2)
On Wed, Feb 11, 2009 at 1:18 AM, markleeds at verizon.net wrote:

            
#
try this:

temp2 <- temp2[order(temp2[,1]),]   # PROBLEM IS HERE
dim(temp2) <- c(5,1)
print(temp2)
On Wed, Feb 11, 2009 at 2:23 PM, <markleeds at verizon.net> wrote:
#
You want to do:

temp2 <- matrix(rnorm(10),nc=1,nrow=10)
rownames(temp2) <- c("a","b","c","d","e","f","g","h","i","j")
print(temp2)
o <- order(temp2[,1])
temp2 <- temp2[o,,drop=FALSE]
print(temp2)

Note that it makes no difference if you drop the dimension of a single
column vector or not when passed to order().

/H
On Tue, Feb 10, 2009 at 10:23 PM, <markleeds at verizon.net> wrote: