Create a Biplot with Linear Regression and Statistical Annotations
create_analysis_biplot.RdThis function creates a biplot using the `plotly` library that displays a scatterplot of two metrics from a given dataframe, fits a linear regression line, and shows key statistical measures (correlation, R², p-value) in a floating text box.
Usage
create_analysis_biplot(
df,
metric_x,
metric_y,
classes = FALSE,
lm = FALSE,
title,
logx = FALSE,
logy = FALSE
)Arguments
- df
A data frame containing the metrics to be plotted.
- metric_x
A string specifying the name of the x-axis metric (column in the dataframe).
- metric_y
A string specifying the name of the y-axis metric (column in the dataframe).
- classes
A boolean indicating whether to group the data by a categorical variable.
- lm
A boolean indicating whether to add a linear regression line.
- title
The title of the graphic
- logx
whether to apply a log scale to X (defaults to FALSE)
- logy
whether to apply a log scale to Y (defaults to FALSE)