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:
Fold Day 0 to Day -1 (making Day 0 an error is problematic due to the ways that I understand the transformation function is called),
Never show fractional days,
Prefer showing weeks (units of 7) when the axis range gets large,
Always show Day -1 and Day 1 to make it clear that Day 0 was skipped on the axis (when the range of days gets very large, that could be a problem because the text "-1" and "1" would overlap), and
Show every day for minor ticks (that could be improved when the number of minor ticks gets large).
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().
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 ofunits
to convert continuous scale numbers to VISITDY numbers and then use that as input likeggplot(my_data, aes(x=as_VISITDY(TSFD, units="hours"), y=y)) + Rsdtm::scale_x_VISITDY() + geom_point()
.Here is an example of its use:
Created on 2021-10-06 by the reprex package (v2.0.1)