This is my first time asking a question here, so please be patient.
I'm having an issue with using order()
This is the data frame. It has 294 observations and 46 variables.
This is the code that I'm using
i <- order(data[ , 17], data[ , 2], decreasing = FALSE)
rdata <-data[i, ]
For ease of reading, I've removed all of the variables except the two that I am ordering by. Here are the results.
What I wanted was for column 17 to be ordered from smallest to largest, and if two or more values in column 17 were the same, for those to be ordered alphabetically by column 2.
For some reason, the results aren't quite correct. Perhaps, I have too many observations or something, but instead of everything being ordered by column 17 (1:294)
it's ordered by column 17 (251:294, 1:250)
Sorry, how else can I share the data?
Basically, rows 251 to 294
should be "prepended" to the beginning of the result data frame
Thank you for your help
i <- order(as.numeric(data[ , 17]), data[ , 2], decreasing = FALSE)
rdata <-data[i, ]
This works properly now.