grantmcdermott / tinyplot

Lightweight extension of the base R graphics system
https://grantmcdermott.com/tinyplot
Apache License 2.0
220 stars 7 forks source link

Should we support `plt(numeric ~ character)`? #217

Open grantmcdermott opened 4 days ago

grantmcdermott commented 4 days ago

And vice versa.

Currently, this fails (as it would for regular plot too).

dat = data.frame(x = letters[1:10], y = 1:10)
tinyplot::plt(y ~ x, dat)

Maybe we should coerce characters to factors internally?

zeileis commented 4 days ago

I'm not sure, stringsAsFactors = TRUE?? My gut feeling is that this is not a good idea. But, then again, in ggplot2 it does work - so maybe we should support it, too?

Would you still default to type = "boxplot"?

grantmcdermott commented 1 day ago

I'm not sure, stringsAsFactors = TRUE??

Ha!

Jokes aside, I do think we should support it, especially many users will likely expect it to work if they are coming from ggplot2 (as you point out). Perhaps the compromise option is not to enforce type = 'boxplot, though, and rather default to 'p'? I don't have strong views here...

zeileis commented 1 day ago

OK, good. I think that treating it like a factor and thus defaulting to boxplots would be easiest to document (and probably implement).

grantmcdermott commented 17 hours ago

Okay cool. Let's keep it simple and do that then. I'm still pretty pressed for time ATM and also need to finalise my 'flip' PR first (currently in draft mode). So please feel free to have a go if you get a chance.

zeileis commented 14 hours ago

I don't have much time either but I quickly put together a trivial PR. See also the caveat that I pointed out in the PR: For the current plots the coercion is appropriate - but it might not be for all future types. I cannot think of an example now, though.