[R] Bar Charts

reichm@@j m@iii@g oii sbcgiob@i@@et reichm@@j m@iii@g oii sbcgiob@i@@et
Thu Oct 17 00:29:39 CEST 2019


Jim

That’s certainly much more straight forward.

Jeff

-----Original Message-----
From: Jim Lemon <drjimlemon using gmail.com> 
Sent: Tuesday, October 15, 2019 8:51 PM
To: Jeff Reichman <reichmanj using sbcglobal.net>
Cc: r-help mailing list <r-help using r-project.org>
Subject: Re: [R] Bar Charts

Hi Jeff,
Let's say you have the following data:

set.seed(12345)
CONTBR_RESULT<-sample(20:200,30)

If you don't mind ordering the results, you can do this:

barplot(rev(sort(CONTBR_RESULT))[1:15],...)

If you want the values in the original order:

barplot(CONTBR_RESULT[order(CONTBR_RESULT) > 15],...)

Jim

On Wed, Oct 16, 2019 at 11:21 AM <reichmanj using sbcglobal.net> wrote:
>
> r-help forum
>
>
>
> I have a database that I have performed a "group_by" of a variable 
> called CONTBR_OCCUPATION. I then simply want to plot out just the top 
> 15 results as a bar plot. How do I plot only the top 15 groups on the 
> x -axis. Should I just extract the top 15 records and plot them or is the a better way?
>
>
>
> occup <- myDat %>%
>
>   group_by(CONTBR_OCCUPATION) %>%
>
>   summarize(count = n()) %>%
>
>   arrange(desc(count))
>
>
>
> Jeff
>
>
>
>
>         [[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