last.plot.get.info {AdhereR}R Documentation

Access last adherence plot info.

Description

Returns the full info the last adherence plot, to be used to modify and/or to add new elements to this plot.

Usage

last.plot.get.info()

Details

This is intended for advanced users only. It may return NULL if no plotting was generated yet, but if one was, a list contaning one named element for each type of plot produced (currently only baseR and SVG are used). For all types of plots there are a set of mapping functions useful for transforming events in plotting coordinates: .map.event.x(x) takes a number of days x, .map.event.date(d, adjust.for.earliest.date=TRUE) takes a Date d (and implictely adjusts for the earilerst date plotted), and .map.event.y(y) takes a row ("event" number) y. Besides the shared elements (see the returned value), there are specific ones as well. For baseR, the members old.par and used.par contain the original (pre-plot) par() environment and the one used within plot(), respectively, in case these need restoring.

Value

A list (possibly empty) contaning one named element for each type of plot produced (currently only baseR and SVG). Each may contain shared and specific fields concerning:

Examples

cma7 <- CMA7(data=med.events[med.events$PATIENT_ID %in% c(1,2),],
             ID.colname="PATIENT_ID",
             event.date.colname="DATE",
             event.duration.colname="DURATION",
             event.daily.dose.colname="PERDAY",
             medication.class.colname="CATEGORY",
             followup.window.start=0,
             followup.window.start.unit="days",
             followup.window.duration=2*365,
             followup.window.duration.unit="days",
             observation.window.start=30,
             observation.window.start.unit="days",
             observation.window.duration=365,
             observation.window.duration.unit="days",
             date.format="%m/%d/%Y",
             summary="Base CMA");
plot(cma7);
tmp <- last.plot.get.info();
names(tmp);
tmp$baseR$legend$box; # legend position and size
head(tmp$baseR$cma$data); # events + plotting info
# Add a transparent blue rect between days 270 and 900:
rect(tmp$baseR$.map.event.x(270), tmp$baseR$.map.event.y(1-0.5),
     tmp$baseR$.map.event.x(900), tmp$baseR$.map.event.y(nrow(tmp$baseR$cma$data)+0.5),
     col=adjustcolor("blue",alpha.f=0.5), border="blue");
# Add a transparent rect rect between dates 03/15/2036 and 03/15/2037:
rect(tmp$baseR$.map.event.date(as.Date("03/15/2036", format="%m/%d/%Y")),
     tmp$baseR$.map.event.y(1-0.5),
     tmp$baseR$.map.event.date(as.Date("03/15/2037", format="%m/%d/%Y")),
     tmp$baseR$.map.event.y(nrow(tmp$baseR$cma$data)+0.5),
     col=adjustcolor("red",alpha.f=0.5), border="blue");

[Package AdhereR version 0.8.1 Index]