[R] sort the data set by one variable

David Winsemius dwinsemius at comcast.net
Wed May 5 18:34:05 CEST 2010


On May 5, 2010, at 12:31 PM, Changbin Du wrote:

>> #sort the data by predicted probability
>> b.order<-bo.id.pred[(order(-predict)),]
>> b.order[1:20,]
>     gene_id    predict
> 43 637882902 0.07823997
> 53 638101634 0.66256490
> 61 639084581 0.08587504
> 41 637832824 0.02461066
> 25 637261662 0.11613879
> 22 637240022 0.06350477
> 62 639084582 0.02238538
> 63 639097718 0.06792841
> 44 637943079 0.04532625
> 80 640158389 0.06582658
> 3  637006517 0.57648451
> 49 638072100 0.01391633
> 4  637007046 0.08999928
> 13 637047086 0.01493464
> 74 639787397 0.01283783
> 58 638936569 0.29182988
> 24 637261661 0.02561841
> 59 639006028 0.31732711
> 38 637585227 0.31272531
> 35 637399473 0.10687524
>
>
>
> HI, Dear R community,
>
> I am sorting the data set bo.id.pred by variable predict, why it  
> does not
> work?

Because "predict" is not the right object name for a column within a  
data.frame.


>  The sequence changed compared with original data set, but you can not
> read any descending pattern.
>
> Thanks!
>
> -- 
> Sincerely,
> Changbin
> --
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list