ggplot2-solutions icon indicating copy to clipboard operation
ggplot2-solutions copied to clipboard

Exercise 5.6.2 #3 use geom_count() as indicated

Open HossamGhorab opened this issue 3 years ago • 0 comments

https://github.com/kangnade/ggplot2-solutions/blob/e6ef9e3b271599f6e97afc0f8a3f012f276f9385/ggplot2_solutions_chapter5.Rmd#L220

The question clearly states

use geom_count() to create a plot

I believe it's a relatively easy & more concise alternative to the geom_bar() you made (which is a good job by the way!). Any of the following lines of code does the job:

ggplot2:::mpg %>% ggplot(aes(drv,trans)) + geom_count(stat = "sum", aes(size = after_stat(prop), group = drv)) # may replace with geom_point()

ggplot2::mpg %>% ggplot(aes(drv,trans)) + stat_sum(aes(size = after_stat(prop), group = drv)) # default geom is "point"

Warmly

HossamGhorab avatar Oct 01 '21 13:10 HossamGhorab