ba_plot: Create a Bland-Altman plot

View source: R/ba_plot.R

ba_plotR Documentation

Create a Bland-Altman plot

Description

Create a Bland-Altman plot

Usage

ba_plot(plotdata, x_var, y_var, x_name, y_name, shape = 16, ...)

Arguments

plotdata

dataframe from which to build the plot

x_var

character expression to evaluate for the x-axis

y_var

character expression to evaluate for the y-axis

x_name

axis label for the x-axis

y_name

axis label for the y-axis

shape

numeric. The point shape to display.

...

further arguments passed to theme

Value

a Bland-Altman plot

References

Bland, J. M., & Altman, D. G. (1986). Statistical methods for assessing agreement between two methods of clinical measurement. lancet, 1(8476), 307-310.

See Also

ba_analysis

Examples

data(ex_data, package = "PAutilities")

# Reduce the number of data points (for illustration purposes) by isolating
# the 150 largest cases

illustration_threshold <-
    quantile(ex_data$Axis1, probs = 1 - (150 / nrow(ex_data)))
ex_data <- ex_data[ex_data$Axis1 > illustration_threshold, ]

# Generate the plot
my_ba <- ba_plot(
    ex_data,
    "(Axis1 + Axis3) / 2",
    "Axis1 - Axis3",
    "mean(Axis1, Axis3)",
    "Axis1 - Axis3"
)

my_ba


# You can add to the plot as you would a normal ggplot object
    my_ba +
      ggplot2::geom_text(
      x = 2000, y = 9000, label = "A",
      size = 8, fontface = "bold", colour = "blue"
      )

# With caution, you can change some automatic options (e.g. color of
# regression line) by overwriting in a new layer

    my_ba + ggplot2::geom_smooth(method = "lm", se = FALSE, colour = "blue")



PAutilities documentation built on Aug. 21, 2022, 9:05 a.m.