[R] order stacked bar plot from total frequency
Jim Lemon
drj|m|emon @end|ng |rom gm@||@com
Thu Sep 16 23:33:32 CEST 2021
Hi Kai,
I don't know about ggplot, but it may be easier to do it before plotting:
set.seed(753)
testdat<-matrix(sample(1:10,9),nrow=3)
# first plot the raw matrix
barplot(testdat)
# then plot the matrix ordered by column sums
barplot(testdat[,order(colSums(testdat))])
Jim
On Fri, Sep 17, 2021 at 4:01 AM Kai Yang via R-help
<r-help using r-project.org> wrote:
>
> Hello List,
> I can order the general bar chart based on frequency, using ggplot2 with the code : aes((reorder(Var1, Freq)), Freq))
> I don't know how to order stacked bar plot by total frequency
> Can you give me some of example?
> Thank you
> Kai
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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