[R] How to order an data.table by values of an column?
Allan Engelhardt
allane at cybaea.com
Thu Jun 11 08:09:18 CEST 2009
See help("order") and help("[.data.frame").
df <-
data.frame(Categ=c(468,351,0,234,117),Perc=c(31.52,27.52,0.77,22.55,15.99))
df[order(df$Categ),]
# Categ Perc
# 3 0 0.77
# 5 117 15.99
# 4 234 22.55
# 2 351 27.52
# 1 468 31.52
Lesandro wrote:
> Hello!
>
> Can you help me? How to order an data.table by values of an column?
>
> Per example:
>
> Table no initial
>
> Categ Perc
> 468 31.52
> 351 27.52
> 0 0.77
> 234 22.55
> 117 15.99
>
> table final
>
> Categ Perc
> 0 0.77
> 117 15.99
> 234 22.55
> 351 27.52
> 468 31.52
>
> Lesandro
>
>
>
> Veja quais são os assuntos do momento no Yahoo! +Buscados
>
> [[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.
>
More information about the R-help
mailing list