Skip to content

ordering

4 messages · Peter Alspach, David Winsemius, Aaron Wells

#
Kia ora Aaron

As you have identified, test[,2] is not numeric - it is probably factor.
Your function must have made the conversion, so you may want to modify
that.  Alternative, try:

test[order(as.numeric(as.character(test[,2]))),] 

BTW, str(test) is a good way to find out more about the structure of
your object.

HTH ....

Peter Alspach
The contents of this e-mail are confidential and may be subject to legal privilege.
 If you are not the intended recipient you must not use, disseminate, distribute or
 reproduce all or any part of this e-mail or attachments.  If you have received this
 e-mail in error, please notify the sender and delete all material pertaining to this
 e-mail.  Any opinion or views expressed in this e-mail are those of the individual
 sender and may not represent those of The New Zealand Institute for Plant and
 Food Research Limited.
#
A) I predict that if you apply the str function to the second test  
that you will find that "con" is not numeric but rather of class  
character or factor. And the second test is probably not a matrix but  
rather a dataframe. Matrices in R need to have all their elements of  
the same class.

B) Read the FAQ ... find the one that tells you how to convert factors  
to numeric.