search for: sortdf

Displaying 2 results from an estimated 2 matches for "sortdf".

2009 Oct 06
2
Problem with na.omit when using length()
...1 0 0 1 1 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 > b [1] 1 1 0 1 1 1 0 0 NA 0 0 0 NA 0 1 NA 0 1 0 0 0 0 NA 0 0 0 0 NA 0 NA 0 1 0 0 #NA refers to no data available. > df=data.frame(sno,a,b) # I'm pasting the sorted data frame below: > sortdf=df[order(a,b),] > sortdf sno a b 3 3 0 0 7 7 0 0 8 8 0 0 10 10 0 0 11 11 0 0 12 12 0 0 14 14 0 0 17 17 0 0 20 20 0 0 21 21 0 0 22 22 0 0 24 24 0 0 25 25 0 0 26 26 0 0 27 27 0 0 29 29 0 0 31 31 0 0 33 33 0 0 34 34 0 0 1 1 0 1 4 4 0 1 9...
2008 Sep 25
2
How to order some of my columns (not rows) alphabetically
Hello, I have a dataframe with 9 columns, and I would like to sort (order) the right-most eight of them alphabetiaclly, i.e.: ID1 ID2 F G A B C E D would become ID1 ID2 A B C D E F G Right now, I'm using this code: attach(data) data<-data.frame(ID1,ID2,data[,sort(colnames(data)[3:9])]) detach(data) but that's not very elegant. Ideally I could specify which columns to sort and