Novartis / xgxr

R package for supporting exploratory graphics at http://opensource.nibr.com/xgx
Other
13 stars 7 forks source link

Feature Suggestion: scale_x_VISITDY to implement skipping day 0 #49

Closed billdenney closed 2 years ago

billdenney commented 2 years ago

For communication with the clinical teams, it is often useful to create figures using the CDISC representation of days where day 0 does not exist (the time scale goes from Day -1, 23 hours, 59 minutes to Day 1, 0 hours, 0 minutes).

I have created a set of functions to implement the trans for ggplot2 which represents VISITDY (or any --DY variable) where 0 does not exist (actually the way I coded it, 0 becomes -1). I currently have the function in my semi-private Rsdtm library (i.e. it is public, but I don't advertise its existence), but I think it would be a better fit in xgxr.

What it does is:

If interested, I could make a PR to put it into xgxr.

I can also imagine a partner function named something like as_VISITDY() that would have an argument of units to convert continuous scale numbers to VISITDY numbers and then use that as input like ggplot(my_data, aes(x=as_VISITDY(TSFD, units="hours"), y=y)) + Rsdtm::scale_x_VISITDY() + geom_point().

Here is an example of its use:

library(ggplot2)
ggplot(data.frame(x=-7:14, y=-7:14), aes(x=x, y=y, label=x)) +
  Rsdtm::scale_x_VISITDY() +
  geom_text()

Created on 2021-10-06 by the reprex package (v2.0.1)

iamstein commented 2 years ago

Bill's implementation: https://github.com/billdenney/Rsdtm/blob/master/R/scale_x_VISITDY.R

iamstein commented 2 years ago

We currently do not plan to implement this feature, but may come back to it at a later date. Thanks for the suggestion!