I have data that looks like this:
score temp
1 a.score 0.05502011
2 b.score 0.02484594
3 c.score -0.07183767
4 d.score -0.06932274
5 e.score -0.15512460
I want to sort the sames based on the values from most negative to most positive, taking the top 4. I try:
> topfour.values <- apply(temp.df, 2, function(xx)head(sort(xx), 4, na.rm = TRUE, decreasing = FALSE))
> topfour.names <- apply(temp.df, 2, function(xx)head(names(sort(xx)), 4, na.rm = TRUE))
> topfour <- rbind(topfour.names, topfour.values)
and I get
> topfour.values
temp[, 1]
d.score "-0.06932274"
c.score "-0.0718376680"
e.score "-0.1551246"
b.score " 0.02484594"
What order is this? What did I do wrong and how do I get it sorted properly?
I've tried method == "Quick" and method == "Shell" as options, but the order still doesn't make sense.