plot_interactive_cma {AdhereRViz} | R Documentation |
Interactive exploration and CMA computation.
Description
Interactively plots the data for one of more patients, allowing the real-time
exploration of the various CMAs and their parameters.
It can use Rstudio
's manipulate
library (deprecated) or
Shiny
(recommended).
Usage
plot_interactive_cma(
data = NULL,
ID = NULL,
cma.class = c("simple", "per episode", "sliding window")[1],
print.full.params = FALSE,
ID.colname = NA,
event.date.colname = NA,
event.duration.colname = NA,
event.daily.dose.colname = NA,
medication.class.colname = NA,
medication.groups = NULL,
date.format = "%m/%d/%Y",
followup.window.start.max = 5 * 365,
followup.window.duration.max = 5 * 365,
observation.window.start.max = followup.window.start.max,
observation.window.duration.max = followup.window.duration.max,
align.all.patients = FALSE,
align.first.event.at.zero = FALSE,
maximum.permissible.gap.max = 2 * 365,
sliding.window.start.max = followup.window.start.max,
sliding.window.duration.max = 2 * 365,
sliding.window.step.duration.max = 2 * 365,
backend = c("shiny", "rstudio")[1],
use.system.browser = FALSE,
get.colnames.fnc = function(d) names(d),
get.patients.fnc = function(d, idcol) unique(d[[idcol]]),
get.data.for.patients.fnc = function(patientid, d, idcol, cols = NA, maxrows = NA)
d[d[[idcol]] %in% patientid, ],
...
)
Arguments
data |
Usually a |
ID |
The ID (as given in the |
cma.class |
The type of CMAs to plot; can be "simple" (CMA0 to CMA9), "per episode", or "sliding window". |
print.full.params |
A logical specifying if the values of all the parameters used to generate the current plot should be printed in the console (if TRUE, it can generate extremely verbose output!). |
ID.colname |
A string, the name of the column in |
event.date.colname |
A string, the name of the column in
|
event.duration.colname |
A string, the name of the column in
|
event.daily.dose.colname |
A string, the name of the column in
|
medication.class.colname |
A string, the name of the column in
|
medication.groups |
A named character vector defining the
medication classes, the name of a column in the data the defines the groups,
or |
date.format |
A string giving the format of the dates used in the
|
followup.window.start.max |
The maximum number of days when the follow-up window can start. |
followup.window.duration.max |
The maximum duration of the follow-up window in days. |
observation.window.start.max |
The maximum number of days when the observation window can start. |
observation.window.duration.max |
The maximum duration of the observation window in days. |
align.all.patients |
Should the patients be aligend? |
align.first.event.at.zero |
Should the first event be put at zero? |
maximum.permissible.gap.max |
The maximum permissible gap in days. |
sliding.window.start.max |
The maximum number of days when the sliding windows can start. |
sliding.window.duration.max |
The maximum duration of the sliding windows in days. |
sliding.window.step.duration.max |
The maximum sliding window step in days. |
backend |
The plotting backend to use; "shiny" (the default) tries to use the Shiny framework, while "rstudio" uses the manipulate RStudio capability. |
use.system.browser |
For shiny, use the system browser? |
get.colnames.fnc |
A function taking as parameter the data source
and returning the column names. Must be overridden when the data source is
not derived from a |
get.patients.fnc |
A function taking as parameter the data source
and the patient ID column name, and returns the list of all patient IDs.
Must be overridden when the data source is not derived from a |
get.data.for.patients.fnc |
A function taking as parameter a (set
of) patient ID(s), the data source, and the patient ID column name, and returns
the list of all patient IDs. Must be overridden when the data source is not
derived from a |
... |
Extra arguments. |
Details
The manipulate
is kept for backward compatibility only, as it is much
more limited than Shiny
and will receive no new development in the
future.
Shiny
currently allows the use of any other data source besides a
default (and usual) data.frame
(or derived), such a connection to an
SQL
database. In this case, the user must redefine the three
argument functions get.colnames.fnc
, get.patients.fnc
and
get.data.for.patients.fnc
which collectively define an interface for
listing the column names, all the patient IDs, and for retreiving the actual
data for a (set of) patient ID(s). A fully worked example is described in
the vignette detailing the access to standard databases storaging the
patient information.
For more info please see the vignette.
Value
Nothing
See Also
The vignette *AdhereR: Interactive plotting (and more) with Shiny*.
Examples
## Not run:
library(AdhereR);
plot_interactive_cma(med.events,
ID.colname="PATIENT_ID",
event.date.colname="DATE",
event.duration.colname="DURATION",
event.daily.dose.colname="PERDAY",
medication.class.colname="CATEGORY");
## End(Not run)