gg_ccc: Plot of raw data with line of best fit and CCC

View source: R/gg_ccc.R

gg_cccR Documentation

Plot of raw data with line of best fit and CCC

Description

Plot of raw data with line of best fit and CCC

Usage

gg_ccc(
  data,
  x,
  y,
  hor = "left",
  ver = "top",
  shift_x = 0,
  shift_y = 0,
  table_font_size = 5,
  table_font_gap = 2.5,
  fixed_coord = TRUE,
  equal_axes_length = TRUE,
  ggdraw_y_shift = NULL,
  ggdraw_x = 0.25,
  ggdraw_text_size = 14,
  add_label = FALSE,
  label_size = 2.5,
  axis_lab_vec = NULL,
  title = NULL
)

Arguments

data

dataframe.

x, y

numeric vectors or characters. If numeric vectors, then they specify the x- and y- plotting variables, respectively. If characters, then they are taken to specify the columns containing the x- and y-variables in data. If not provided, then the x- and y-plotting variables are taken as the first two columsns of data. x and y must have the same type, and anything else generates an error.

hor

'left' or 'right'. Specifies horizontal position of summary statistic table. Default is 'left'.

ver

'top' or 'bottom'. Specifies vertical position of summary statistic table. Default is 'top'.

shift_x

numeric. Percentage of x-axis range to shift summary statistic table. If positive, then the table is shifted to the right. For example, shift_x=50 means that the table will be shifted halfway across the width of the x-axis range. Default is zero.

shift_y

numeric. Analogous to shift_x, but for the y-axis. Positive values move upwards. Default is 0.

table_font_size

numeric. Size of font for summary statistic table.

table_font_gap

numeric. Percentage of range of y-axis that rows in table are separated by.

fixed_coord

logical. If TRUE, then a one-unit increase in the y-axis is visually represented the same length as one-unit increase on the x-axis. Default is TRUE.

equal_axes_length

logical. If TRUE, then x- and y-axes have the same range. The range is set so that there all data points are displayed (with a slight buffer around the upper and lower endpoints). Default is TRUE.

ggdraw_y_shift

numeric. Provides the increase in the y-coordinate from one table entry to the next. A reasonable value is 0.03. Default is NULL, in which case the table is placed according to the old method (using shift_x, shift_y, table_font_gap).

ggdraw_x

numeric. X-axis coordinate for ggdraw text. Default is 0.25.

ggdraw_text_size

numeric. Font size for ggdraw text. Default is 14.

add_label

logical. If TRUE, then each point is labelled using ggrepel::geom_text_repel. Default is FALSE.

title

character. Title to give plot. Default is NULL.

Details

The following summary statistics are printed on the plot:

  • Concordance CC: est (95% CI)

  • Pearson's CC: est (95% CI)

  • Intercept: est (95% CI)

  • Slope: est (95% CI)

Value

A ggplot2 plot with the following elements:

  • raw data plotted

  • black 45 degree line

  • blue linear line of best fit (estimate + confidence bands)

  • table of relevant summary statistics.

Examples

data( test_tbl )
gg_ccc( test_tbl )

MiguelRodo/ggccc documentation built on Nov. 11, 2023, 11:48 a.m.