davedgd / ggNestedBarChart

An easier way to create nested, grouped, heirarchical bar charts with ggplot2
4 stars 0 forks source link

problem in merging group label #3

Closed cocoaawil closed 2 weeks ago

cocoaawil commented 2 weeks ago

Dear Sir, I'm interested in your R library. I tried to use the example from tutorial but p2.png can not change merged group in first header such as Automatic show in three repeat words. I'm not sure how to fix it. I'm looking forward to hearing from you. Thank you very much.

davedgd commented 2 weeks ago

Hello! I looked into this issue and you are right: This package seems to have stopped working due to some changes in ggplot2 that occured in the past 1-2 years. I was able to run the code by downgrading both R and the ggplot2 package to 2022 versions, and all went well.

That said, obviously downgrading R isn't a real solution, so I looked into fixing the actual code. However, while looking at it, I cam across another package, ggh4x, which provides a much cleaner solution to this problem. Assuming you recreate p1 using the example code, you can generate a plot essentially like p2 using the following:

library("ggh4x")

p3 <- p1 + facet_nested(~ am + vs + gear, scales = TRUE, space = TRUE)
ggsave("p3.png", width = 20, height = 5)

This code will produce the following output, which compares favorably with p2 shown on the home page of this repo:

p3

@cocoaawil: Could you give this a try? If this works for you, I'll archive this repo and forward people over to ggh4x.

cocoaawil commented 2 weeks ago

@cocoaawil: Could you give this a try? If this works for you, I'll archive this repo and forward people over to ggh4x.

Thank you very much. It works. I got the figure same as p2.png. How can I cite your R library?

davedgd commented 2 weeks ago

You're very welcome @cocoaawil! Given that my package no longer really works, you're very kind, but there's no reason to cite my package at this point. Instead, please go ahead and cite ggh4x using the details provided here: https://teunbrand.github.io/ggh4x/authors.html#citation

Just in case you did need a citation to this repo for some specific reason, I created a Zenodo release here that could be used: https://doi.org/10.5281/zenodo.12706857

Lastly, I'm going to go ahead and archive this repo and redirect people to ggh4x as noted in the prior comment.

Thanks again for bringing this to my attention!