jointmetaplot: Produce plots of longitudinal and survival outcomes

Description Usage Arguments Value See Also Examples

View source: R/jointmetaplot.R

Description

This function can produce plots for each study in the dataset of the longitudinal trajectory pannelled by event type with or without a smoother, and kaplan-meier plots for each study which plot the survival probability against time.

Usage

1
2
3
jointmetaplot(dataset, study, longoutcome, longtime, survtime, cens, id,
  smoother = FALSE, studynames = NULL, type = c("Longitudinal", "Event",
  "Both"), eventby = NULL, eventconfint = FALSE)

Arguments

dataset

a jointdata object

study

the name of the variable holding study membership in the supplied dataset

longoutcome

the name of the variable holding the longitudinal outcome in the supplied dataset

longtime

the name of the variable holding the longitudinal time variable in the supplied dataset

survtime

the name of the variable holding the survival time variable in the supplied dataset

cens

the name of the variable holding the censoring variable in the supplied dataset

id

the name of the variable holding the id in the supplied dataset

smoother

a logical indicating whether or not a smoother should be displayed on the longitudinal plot

studynames

a vector of character strings giving the names to label the study plots by - the first element of this vector will be the label for the plots for the first study in the dataset for both the longitudinal and the survival plots

type

option to select what type of plots should be returned. If just plots of the longitudinal trajectories are required then type = 'Longitudinal'. Else if just plots of the survival probabilities are required then type = 'Survival'. Finally if both survival and longitudinal plots are required then this should be set to type = 'Both'

eventby

an optional character string giving a grouping variable that the graph of survival probability by time will be split by.

eventconfint

a logical value indicating whether the survival plot should contain confidence intervals or not. Defaults to FALSE.

Value

Returns an object of class 'jointplots'. This contains an element labelled 'longplots' if type in the function call is set to one of 'Longitudinal' or 'Both', and an element labelled 'eventplots' if type in the function call is set to one of 'Survival' or 'Both'. The element 'longplots' is a list of ggplot2 objects plotting the longitudinal trajectories for each study, and is of length equal to the number of studies in the supplied dataset. The element 'eventplots' is a list of ggplot2 objects plotting the survival probabilities for each study and is of length equal to the number of studies in the supplied dataset.

To plot a particular graph, it can be called by position from the relevent element of the returned 'jointplots' in the same way that an element in a particular position is called from a list, or it can be called by name if study.names supplied to the function call.

This function supplies separate plots for each study in the dataset. To arrange these plots into one grid, use the function jointmetaplotall.

See Also

jointdata, ggplot, jointmetaplotall

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
    #change data to jointdata format
    jointdat<-tojointdata(longitudinal = simdat$longitudinal,
                          survival = simdat$survival, id = 'id',
                          longoutcome = 'Y', timevarying = c('time','ltime'),
                          survtime = 'survtime', cens = 'cens',
                          time = 'time')

    #ensure variables are correctly formatted
    jointdat$baseline$study <- as.factor(jointdat$baseline$study)
    jointdat$baseline$treat <- as.factor(jointdat$baseline$treat)

    #produce plots
    sepplots<-jointmetaplot(dataset = jointdat, study = 'study',
                        longoutcome = 'Y', longtime = 'time',
                        survtime = 'survtime', cens = 'cens', id = 'id',
                        smoother = TRUE, studynames = c('Study 1', 'Study 2',
                        'Study 3', 'Study 4', 'Study 5'), type = 'Both')

mesudell/joineRmeta documentation built on Jan. 24, 2020, 6:06 p.m.