subjectProfileSummaryPlot: Plot subject summary profile.

View source: R/subjectProfileSummaryPlot.R

subjectProfileSummaryPlotR Documentation

Plot subject summary profile.

Description

The user can either specify a variable for the standard error (seVar), or directly the variables for the minimum and maximum values for the error bars (minVar, maxVar).

Usage

subjectProfileSummaryPlot(
  data,
  xVar = NULL,
  xLab = getLabelVar(xVar, labelVars = labelVars),
  xAxisExpand = waiver(),
  xGap = NULL,
  xGapDiffNew = NULL,
  meanVar = "statMean",
  seVar = if ("statSE" %in% colnames(data)) "statSE",
  minVar = NULL,
  maxVar = NULL,
  yLab = paste(c(sub("^stat", "", meanVar), if (!is.null(minVar) & !is.null(maxVar)) {
  
      paste0("(", sub("^stat", "", minVar), ", ", sub("^stat", "", maxVar), ")")
 } else
    if (!is.null(seVar)) paste("+-", sub("^stat", "", seVar))), collapse = " "),
  facetVar = NULL,
  facetScale = "free_y",
  colorVar = NULL,
  colorLab = getLabelVar(colorVar, labelVars = labelVars),
  colorPalette = NULL,
  labelVars = NULL,
  useLinetype = TRUE,
  linetypePalette = NULL,
  useShape = TRUE,
  shapePalette = NULL,
  jitter = NULL,
  title = NULL,
  caption = NULL,
  yTrans = NULL,
  yLim = NULL,
  xLim = NULL,
  yAxisExpand = c(0.05, 0.05),
  yLimExpand = NULL,
  xAxisLabs = NULL,
  sizePoint = GeomPoint$default_aes$size,
  sizeLine = GeomLine$default_aes$size,
  sizeLabel = GeomText$default_aes$size,
  widthErrorBar = GeomErrorbar$default_aes$width,
  tableText = NULL,
  tableTextFontface = 1,
  tableHeight = 0.1,
  tableYAxisLabs = !is.null(colorVar),
  tablePlotMargin = unit(0, "pt"),
  label = FALSE,
  labelPadding = unit(1, "lines"),
  byVar = NULL,
  hLine = NULL,
  hLineColor = "black",
  hLineLty = "solid",
  vLine = NULL,
  vLineColor = "black",
  vLineLty = "solid",
  style = "report",
  fontname = switch(style, report = "Times", presentation = "Tahoma"),
  fontsize = switch(style, report = 8, presentation = 10),
  themeFct = switch(style, report = theme_classic, presentation = theme_bw),
  themeIncludeVerticalGrid = TRUE,
  ggExtra = NULL,
  legendPosition = ifelse(!is.null(tableText), "none", "bottom"),
  ...
)

Arguments

data

Data.frame with summary statistics to represent in the plot, e.g. a summaryTable object.

xVar

String, variable of data with variable for the x-axis.

xLab

String with label for the xVar.

xAxisExpand

Object passed to the 'expand' parameter of: scale_x_continuous, (waiver by default).

xGap

(optional) Numeric vector of length 2 for which a gap should be created in the x-axis. Only available if xVar is specified and a numeric variable. Records with xVar within xGap are filtered from the plot, vertical lines are included at the min/max of the gap, and the gap is represented as '//' in the x-axis of the plot.

xGapDiffNew

Numeric vector of length 2 with new range of the xGap. If not specified, the minimum difference between consecutive x elements in the data is used.

meanVar

String, variable of data with the mean variable.

seVar

String, variable of data with the standard error.

minVar, maxVar

String, variables of data with minimum and maximum value for error bar. If both are specified, seVar is ignored.

yLab

String with label for the y-axis. If different labels should be used for different elements of byVar variable, the vector should be named with each corresponding element (collapsed with '.' if multiple).

facetVar

Character vector, variable(s) of data for facetting.

facetScale

String with type of scale used for facetting, 'free_y' by default (fixed scale in the x-axis and free in the y-axis).

colorVar

String, variable of data for coloring.

colorLab

String, label for colorVar, used in the legend.

colorPalette

(named) Vector with color palette.

labelVars

Named string with variable labels (names are the variable code).

useLinetype

Logical, if TRUE (FALSE by default) use also linetype to differenciate the variable specified via colorVar in the mean line.

linetypePalette

Vector with linetype(s), in case useLinetype is TRUE.

useShape

Logical, if TRUE (by default) colorVar is also used for the shape.

shapePalette

Named vector with shape palette for colorVar.

jitter

Numeric with jitter for the x-axis, only used if colorVar specified.

title

String with title for the plot. If different labels should be used for different elements of byVar variable, the vector should be named with each corresponding element (collapsed with '.' if multiple).

caption

String with caption for the plot, NULL by default.

yTrans

(optional) String with transformation for the y-axis. Currently only 'log10' (or NULL, default) is available. In case error bars go in the negative, their values are set to a 'small enough' value for plotting: min(data)/10 or yLim[1] if yLim is specified.

yLim

Vector of the length 2 with limits for the y-axis.

xLim

Vector of the length 2 with limits for the x-axis.

yAxisExpand

Expansion constants for the limits for the y-axis. See the documentation of the expand parameter of the scale_y_continuous function for the available values for this parameter.

yLimExpand

This parameter is deprecated, use yAxisExpand instead.

xAxisLabs

(optional) Named character vector with labels for the x-axis.

sizePoint

Size for the point.

sizeLine

Size for the line linking means and error bars.

sizeLabel

Size for the label, only used if label is not NULL.

widthErrorBar

Numeric vector of length 1 with width of error bar.

tableText

(optional) Character vector with colname of data or expression from colnames of data to be represented in the table below the plot. By default, no table is displayed.

tableTextFontface

Font face for the text included in the table.

tableHeight

Numeric of length 1 with height for the table.

tableYAxisLabs

Logical, if TRUE (by default) the labels of the colorVar are included in the y-axis of the table.

tablePlotMargin

Margin between the plot and the table, expressed as unit, 0 by default.

label

Logical or expression or list of expression. Points are labelled with meanVar if set to TRUE, or with the specified expression if label is an expression. If a list is specified, 'textLabel' (required) should contain expression to extract label, and 'textHjust' and 'textVjust' (optional) may contain expression specifying horizontal and vertical adjustment of the label.

labelPadding

Amount of padding (space) between each point and its label, 1.5 lines by default. See parameter point.padding of the geom_text_repel function.

byVar

Variable(s) of data for which separated plot(s) should be created.

hLine

(optional) numeric with y-intercept of line(s) to be added. If different thresholds should be used for different elements of the byVar or facetVar variables, the vector should be named with each corresponding element (collapsed with '.' if multiple).

hLineColor

String with color for hLine, 'black' by default.

hLineLty

String with linetype for hLine, 'solid' by default.

vLine

(optional) numeric with x-intercept of line(s) to be added. If different thresholds should be used for different elements of the byVar or facetVar variables, the vector should be named with each corresponding element (collapsed with '.' if multiple).

vLineColor

String with color for vLine, 'black' by default.

vLineLty

String with linetype for vLine, 'solid' by defaul

style

String with subject profile style. This affects the parameters: fontname, fontsize and themeFct.

fontname

String with font name, by default 'Times' if style is 'report' and 'Tahoma' if style is 'presentation'.

fontsize

Numeric vector of length 1 with font size, by default 8 if style is 'report' and 10 if style is 'presentation'

themeFct

Function with ggplot2 theme, by default theme_classic if style is 'report' and theme_bw if style is 'presentation'.

themeIncludeVerticalGrid

Logical, if TRUE (by default) include theme vertical grid lines (if present in themeFct).

ggExtra

Extra ggplot call of function generating such call(s) to be added in main plot.
Multiple calls are set via a function, e.g. ggExtra = function(gg){gg + geom_vline(...) + geom_hline(...)}.
If different calls should be used for different elements of the byVar variable, the vector should be named with each corresponding element (collapsed with '.' if multiple).

legendPosition

String with legend position. By default, 'bottom' of tableText is not specified, 'none' otherwise.

...

Additional parameters for geom_text_repel or geom_text used for the label.

Value

ggplot object or list of such objects of byVar is specified.

Author(s)

Laure Cougnaud


inTextSummaryTable documentation built on June 22, 2024, 9:24 a.m.