trajPlot: Plot Individual Subject Trajectories

View source: R/trajPlot.R

trajPlotR Documentation

Plot Individual Subject Trajectories

Description

trajPlot will plot individual subject trajectories for multi-batch longitudinal data. Each line represents a trajectory of observations of a single feature (e.g., left fusiform cortical thickness) over time for an individual subject. Plotting points are coded by batch. Data should be in "long" format.

Usage

trajPlot(
  idvar,
  timevar,
  feature,
  batchvar,
  data,
  point.shape = NULL,
  point.col = NULL,
  line.col = NULL,
  line.type = NULL,
  xlabel = "time",
  ylabel = "feature",
  title = "",
  xlimits = NULL,
  ylimits = NULL,
  margins = c(5, 5, 3, 1),
  verbose = TRUE,
  ...
)

Arguments

idvar

character string that specifies name of ID variable. ID variable can be factor, numeric, or character.

timevar

character string that specifies name of numeric variable that distinguishes within-subject repeated measures, e.g., time, age, or visit. Will be plotted along x-axis.

feature

character string that specifies name of the numeric feature variable to be plotted over time, or the numeric index of the corresponding column. Will be plotted along y-axis.

batchvar

character string that specifies name of the batch variable. Batch variable should be a factor. Will determine the shape of plotting points.

data

name of the data frame that contains the variables above. Rows are different observations (subject/timepoints), columns are different variables.

point.shape

optional numeric vector that encodes the point shape for the batch variable levels. If not using default setting, length should be equal to number of unique observations included (nrow(data)) and in the same order as in the data frame. See the pch argument in points. Default cycles through pch=c(1:25, 0) by batch level.

point.col

optional vector that encodes colors of the point for each observation (character string of color names or hexadecimal codes). Length should be equal to number of unique observations included (nrow(data)) and in the same order as in the data frame. Default is 'black' for all.

line.col

optional vector that encodes colors of the line for each subject (character string of color names or hexadecimal codes). Length should be equal to number of unique subjects included (length(unique(data[,idvar]))) and in the same order as in the data frame. Default is 'black' for all.

line.type

optional numeric or character vector that encodes line type for each subject. Length should be equal to number of unique subjects included (length(unique(data[,idvar]))) and in the same order as in the data frame. See the lty argument in par. Default is 'solid' for all.

xlabel

x-axis label (character string). Default is 'time'.

ylabel

y-axis label (character string). Default is 'feature'.

title

main title for the plot (character string). Default is no title.

xlimits

two dimensional numeric vector giving minimum and maximum x-axis values. Default is minimum and maximum time variable values.

ylimits

two dimensional numeric vector giving minimum and maximum y-axis values. Default is minimum and maximum feature variable values.

margins

numeric vector of 4 values specifying margins in the order (bottom, left, top, right).

verbose

prints messages. Logical TRUE or FALSE. Default is TRUE.

...

other graphical parameter arguments passed to par.

Value

Creates a plot.


jcbeer/longCombat documentation built on June 26, 2022, 6:47 p.m.