added tinyplot.data.frame method#613
Conversation
grantmcdermott
left a comment
There was a problem hiding this comment.
Some specific (and high-level) thoughts in my review below. Happy to discuss!
| ## 2d: y ~ x | ||
| ## 3d: pairs? (not supported, yet) | ||
| if (is.null(formula)) { | ||
| if (ncol(x) > 2L) stop("'formula' is missing with no default for more than 2 columns") |
There was a problem hiding this comment.
Hmmm, I think we could do better than erroring out here. My own preference is that we either:
-
Subset to the first 2 columns and display the resulting simple two-way plot (maybe with a message), or
-
Subset to the first N (<=5?) columns and then internally implement the "manual" pairs-esque plot that you demonstrate in the Examples above (maybe with a message if any columns are dropped), or
-
Don't subset at all and just try to implement the "manual" pairs-esque plot you demonstrate above (but risk poor viewability/zooming.)
P.S. I don't think we should try to mimic base plot(df)/pairs(df) exactly. Apart from the top + right axes variation being a pain, I think your example shows several improvements, especially w.r.t. to the histogram and way that factor/character variables are handled consistently (barplots + spineplots).
P.P.S. If we go with option 2 or 3, one other thing to consider is whether we support an (atomic) by argument without a formula. E.g., tinyplot(iris, by = "species").
There was a problem hiding this comment.
You are right. I think we should just go for 3 and explain the limitations in the manual page.
There was a problem hiding this comment.
I have attempted to implement 3 now including some very simple setting of xlab, ylab, and main. It's not great but probably better than nothing. Further improvements would be welcome.
| #' or without a formula. The case with the formula mainly facilitates | ||
| #' using `tinyplot()` in combination with pipes. The case without | ||
| #' formula provides a quick way of plotting the variables in data frames, | ||
| #' either only one variable or a pair of variables. In the future, the |
There was a problem hiding this comment.
See my comment about the n>2 case below.
There was a problem hiding this comment.
I have updated it a little bit now. But depending on where we go with the pairs-esque display, further updates will probably be necessary.
Replaces #347
The new
data.framemethod fortinyplot()draws some inspiration from the corresponding method for baseplot(). It mainly facilitates usingtinyplot()with data frames and pipes.Currently, this only works for data frames with 1 or 2 variables. In the future we might add a pairs-style display as follows but this would require better handling of axes and their labels.
So far the PR only contains code and documentation. NEWS and tests can be added when we agree on the code.