Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upConsider returning ggplot object instead of relying on print() #14
Comments
|
Hi @gadenbuie thanks for the suggestion & the examples. This is a great point, I totally agree. This should be an easy fix, though I need to iron out some warnings that get emitted by printing some of the plots. I'll get back when I have an update. Thanks! |
|
Hi @gadenbuie, this is now addressed by this commit. The next CRAN submission will follow shortly. Thanks again! |
Hi @alastairrushworth and thanks for this awesome package! I turn to it frequently to get a sense of new datasets.
One point of friction for me is that
show_plot()doesn't return the ggplot2 object created by lower-level functions likeplot_cat(). Currently, I believe that iftype$method == "types"inshow_plot()the result will be the ggplot2 object but otherwise, because of the if statements throughoutshow_plot(), the result will always beNULL.This makes it difficult for users who would like to work with the ggplot2 object, to add or change styles, for example, because they need to fall back to using
:::to accessinspectdf:::plot_cat()or similar. Unfortunately for these users, the default values forplot_cat()are handled byshow_plot(), further increasing friction.If I provide the default values to the lower level functions, then I can gain access to the created ggplot2 object, but it's clear that
plot_cat()isn't designed for end user consumption.Personally, I would prefer that
show_plot()simply return the ggplot2 object and that default printing rules are used to display the plot rather than explicitly callingprint()internally. In this way,show_plot()would work as in the last example, but without automatically printing the plot. Doing this would give the user more control over where and how the inspectdf plots are used.Created on 2019-07-23 by the reprex package (v0.2.1)