You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One-way, two-way, and three-way tabyls lend themselves to simple visualizations. Reshaping them for ggplot, however, requires additional finagling. An autoplot method would create simple, predictable charts. What I imagine is something like the code below, with a 'ggplot' object returned and options to label the bars, use % instead of n, position = dodge/stack, etc.
I'd be willing to try and cook this up and open a PR. Otherwise, I may introduce this functionality in a separate package.
Thanks for this suggestion! I am open to it. I once made canned autoplot-type functions for recurring plots at my previous employer, and it was tough because invariably the user would want to tweak it a little and then it became harder than if they'd built it up themselves.
That said, I think our case is different. These are just supposed to be exploratory, not publication ready. Which is analogous to how janitor::tabyl relates to other packages that are more complex in their tables.
I think it may be tricky to navigate being minimal and extensible while also providing some options. But doable. I'd generally prefer to err on the side of it being just the first few lines of a ggplot2 call, with the data, aes, and geom. But then letting users tinker with the other stuff (theme, labels, etc.) using ggplot2 code.
It might help you that the variable names are stored as attributes of the tabyl. In your case try attr(t2, "var_names").
Overall, it would be cool to be able to pipe a tabyl into a chart in a single line! Even the most of the janitor package is stable, this could be functionality that evolves and is perfected over time.
I don't plan to implement this, so am closing as unplanned. I would be open a completed PR - if anyone wants to send one, please reply to this thread to discuss specs before you start coding (recommended).
Feature request: autoplot method
One-way, two-way, and three-way tabyls lend themselves to simple visualizations. Reshaping them for ggplot, however, requires additional finagling. An autoplot method would create simple, predictable charts. What I imagine is something like the code below, with a 'ggplot' object returned and options to label the bars, use % instead of n, position = dodge/stack, etc.
I'd be willing to try and cook this up and open a PR. Otherwise, I may introduce this functionality in a separate package.
The text was updated successfully, but these errors were encountered: