Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

create pie charts with facet wrap?

I manage to create a dataframe as shown but I dont know how to create faceted pie charts out of it. Can someone show me how? Thanks in advance.
enter image description here

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I am not sure what you want to show, so you could do something like this:

df <- data.frame(rideable_type = c("classic_bike", "classic_bike", "docked_bike", "electric_bike", "electric_bike"),
                 member_causal = c("causal", "member", "causal", "causal", "member"),
                 number_of_bikes = c(1313878, 2013712, 308241, 1048194, 1250025),
                 total = c(2670303, 3263737, 2670303, 2670303, 3263737),
                 freq = c(49.2, 61.6, 11.5, 39.2, 38.3))


library(ggplot2)
ggplot(df, aes(x = factor(1), fill=factor(rideable_type))) + 
  facet_wrap(~member_causal) + 
  geom_bar(width = 1,position = "fill") + 
  coord_polar(theta="y") +
  labs(fill = "rideable type", x = "", y = "") 

Created on 2022-07-08 by the reprex package (v2.0.1)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading