[R] How to sort frequency distribution table?
Petr PIKAL
petr.pikal at precheza.cz
Thu Mar 8 08:48:48 CET 2012
Hi
Just order your table output.
xx<-sample(letters[1:5], 100, replace=T)
yy<-table(xx)
barplot(yy[order(yy, decreasing=T)])
Regards
Petr
>
>
> Hi,
>
> I am working on categorical data with column as disease name(categaory).
>
> My input data is
> [1] Acute lymphoblastic leukemia (childhood)
> [2] Adiponectin levels
> [3] Adiponectin levels
> [4] Adiponectin levels
> [5] Adiponectin levels
> [6] Adiponectin levels
> [7] Adiposity
> [8] Adiposity
> [9] Adiposity
> [10] Adiposity
> [11] Age-related macular degeneration
> [12] Age-related macular degeneration
> [13] Aging (time to death)
> [14] Aging (time to event)
> [15] Aging (time to event)
> [16] Aging (time to event)
> [17] Aging (time to event)
> [18] AIDS
> [19] AIDS
> [20] AIDS
> .....
>
>
> when i use table command, i get
>
>
> [,1]
> Acute lymphoblastic leukemia (childhood) 1
> Adiponectin levels
> 5
> Adiposity
> 4
> Age-related macular degeneration
> 2
> Aging (time to death)
> 1
> ......
>
> But i need to sort this table by frequency and need to plot a histogram
with
> lable first column (e.g. Adiposity , Age-related macular degeneration as
> bar name). How can i do it?
>
> Regards
>
> --
> View this message in context: http://r.789695.n4.nabble.com/How-to-sort-
> frequency-distribution-table-tp4455595p4455595.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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