tidyverse / ggplot2

An implementation of the Grammar of Graphics in R
https://ggplot2.tidyverse.org
Other
6.41k stars 2k forks source link

Clarify the current status of fortify() #3816

Open yutannihilation opened 4 years ago

yutannihilation commented 4 years ago

(Originally commented at https://github.com/tidyverse/ggplot2/pull/3802#issuecomment-583852613)

In my understanding, there are 2 purposes of fortify().

  1. User-facing utility to convert an object to data.frame, which otherwise the users don't know how to.
  2. API for developers that let the custom objects handled nicely in the internal of ggplot2 by tweaking the object at the very first stage.

For purpose 1, ggplot2 now provides 2 types of methods, both of which are becoming less important:

So, we can and should deprecate (or at least discourage) this type of usages.

On the other hand, for purpose 2, I think fortify() still plays a somehow important role. For example, fortify.tbl() ensures tbl is collect()ed.

https://github.com/tidyverse/ggplot2/blob/0137a4d7a25f6ffa3c80cd3e9626a9b0dbc22482/R/fortify.r#L19-L24

Suggestions

I suggest

Note that this issue is not very high priority as maintaining fortify() doesn't seem a heavy burden, at least at the moment. I filed this issue just because it seems we need some place to discuss to avoid confusion. Anyway, I believe it's a right move to encourage users to use broom and sf.

hadley commented 2 years ago

This sounds like a good proposal to me, but it'll need to wait until a major/minor release.