sahirbhatnagar / casebase

http://sahirbhatnagar.com/casebase/
Other
9 stars 5 forks source link

Creating custom geom/stat for population time plots #7

Closed sahirbhatnagar closed 8 years ago

sahirbhatnagar commented 8 years ago

What do you think about creating a casebase stat and geom to make population time plots? We could then take advantage of faceting if we want a population time plot by exposure status or some other covariate of interest. Of course, another advantage would be that the rest of the ggplot2 functions would also become available. Things to consider:

  1. Is the juice worth the squeeze?
  2. Base R graphics might still be the way to go since its highly customizable and I've never created a geom before. This option is relatively new to ggplot2
  3. What if users aren't familiar with ggplot2?
  4. Should we give the user the option of choosing?
sahirbhatnagar commented 8 years ago
  1. I spent a whole day and determined, that the juice is not worth the squeeze. Main reason being that a population time plot uses existing geoms such as point, segment or polygon. Creating a stat or geom would require lots of time because we would somehow need to map the user input (time and event variables) to at least 4 parameters of the geom_segment (x, xend, y, yend).

I have instead opted for a simpler two-step approach: 1) create a function that gets the data into the right format, 2) create plot methods (which is a wrapper of ggplot2 functions) for the objects created in step 1. See #17 for details of this implementation