Hi, That is not what I get. After running your code I get
levels(df.m$Period) [1] "1991-00" "1901-10" "1981-90" "2001-06" "1911-20" "1881-90" "1971-80" [8] "1921-30" "1891-00" "1961-70" "1871-80" "1851-60" "1951-60" "1861-70" [15] "1841-50" "1941-50" "1831-40" "1931-40" "1820-30" this is my version info: sessionInfo() R version 2.14.1 (2011-12-22) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] ggplot2_0.9.0 reshape_0.8.4 plyr_1.7.1 loaded via a namespace (and not attached): [1] colorspace_1.1-1 dichromat_1.2-4 digest_0.5.1 grid_2.14.1 [5] MASS_7.3-16 memoise_0.1 munsell_0.3 proto_0.3-9.2 [9] RColorBrewer_1.0-5 reshape2_1.2.1 scales_0.1.0 stringr_0.6 what is yours? Best, Ista On Sunday, February 19, 2012 11:59:30 PM vd3000 wrote: > > df <- structure(c(106487, 495681, 1597442, > > 2452577, 2065141, 2271925, 4735484, 3555352, > 8056040, 4321887, 2463194, 347566, 621147, > 1325727, 1123492, 800368, 761550, 1359737, > 1073726, 36, 53, 141, 41538, 64759, 124160, > 69942, 74862, 323543, 247236, 112059, 16595, > 37028, 153249, 427642, 1588178, 2738157, > 2795672, 2265696, 11951, 33424, 62469, > 74720, 166607, 404044, 426967, 38972, 361888, > 1143671, 1516716, 160037, 354804, 996944, > 1716374, 1982735, 3615225, 4486806, 3037122, > 17, 54, 55, 210, 312, 358, 857, 350, 7368, > 8443, 6286, 1750, 7367, 14092, 28954, 80779, > 176893, 354939, 446792, 33333, 69911, 53144, > 29169, 18005, 11704, 13363, 18028, 46547, > 14574, 8954, 2483, 14693, 25467, 25215, > 41254, 46237, 98263, 185986), .Dim = c(19, > 5), .Dimnames = list(c("1820-30", "1831-40", > "1841-50", "1851-60", "1861-70", "1871-80", > "1881-90", "1891-00", "1901-10", "1911-20", > "1921-30", "1931-40", "1941-50", "1951-60", > "1961-70", "1971-80", "1981-90", "1991-00", > "2001-06"), c("Europe", "Asia", "Americas", > "Africa", "Oceania"))) > > > df.m <- melt(df) > > df.m <- rename(df.m, c(X1 = "Period", X2 = "Region")) > > > > df.m <- transform(df.m, Period = reorder(Period, -1*value)) > > > > ggplot(df.m, aes(x = Period, y = value/1e+06, fill = Region)) + > > geom_bar(stat = "identity", position = "stack") > > ===================================================== > > > levels(df.m$Period) > > [1] "1820-30" "1831-40" "1841-50" "1851-60" "1861-70" "1871-80" "1881-90" > [8] "1891-00" "1901-10" "1911-20" "1921-30" "1931-40" "1941-50" "1951-60" > [15] "1961-70" "1971-80" "1981-90" "1991-00" "2001-06" > ===================================================== > I think after reordering, the levels changed, but the fact was nothing has > got change >_<!!! > > I found I have many commands happen like this. especially drawing > graph...ordering doesn't work... > [[elided Yahoo spam]] > it is crazy, "R" teases me. > > > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/ggplot-rank-stack-bar-automatically-tp4391042 > p4403442.html Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@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. ______________________________________________ R-help@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.