Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: autoplot method for class 'tabyl' #468

Closed
daranzolin opened this issue Jan 19, 2022 · 2 comments
Closed

Feature request: autoplot method for class 'tabyl' #468

daranzolin opened this issue Jan 19, 2022 · 2 comments
Labels
seeking comments Users and any interested parties should please weigh in - this is in a discussion phase!

Comments

@daranzolin
Copy link

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.

t1 <- tabyl(mtcars, cyl)
t2 <- tabyl(mtcars, cyl, gear)
t3 <- tabyl(mtcars, cyl, gear, am)

autoplot(t1)
autoplot(t2)
autoplot(t3)

image

image

image

@sfirke
Copy link
Owner

sfirke commented Jan 19, 2022

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.

@sfirke sfirke added the seeking comments Users and any interested parties should please weigh in - this is in a discussion phase! label Jan 19, 2022
@sfirke
Copy link
Owner

sfirke commented Aug 19, 2023

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).

@sfirke sfirke closed this as not planned Won't fix, can't repro, duplicate, stale Aug 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
seeking comments Users and any interested parties should please weigh in - this is in a discussion phase!
Projects
None yet
Development

No branches or pull requests

2 participants