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 pass
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, wrote:
> 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 fo
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(te
3 matches
Mail list logo