FunRegressionPlot: Plot linear regression

View source: R/FunRegressionPlot.R

FunRegressionPlotR Documentation

Plot linear regression

Description

Computes a linear model (lm), plots the regression line, the linear equation and the adj R square value.

Usage

FunRegressionPlot(
  x = rnorm(10, 10, 2),
  y = rnorm(10, 10, 2),
  edge = c(0.1, 0.9),
  col = "black",
  regression_line = T,
  x_log_transformed = F,
  y_log_transformed = F
)

Arguments

x

independent variable

y

dependent variable

edge

vector in the form c(x,y), defines the position of the linear equation and the adj R square value. The coordinates are given as normalized device coordinates.

col

color of regression line and text

regression_line

logical, should a regression line be plotted

x_log_transformed

logical, indicate a log transformation of the x axis The formula would be lm(log(x), y). Possible in combination with y_log_transformed.

y_log_transformed

logical, indicate a log transformation of the y axis The formula would be lm(x, log(y)). Possible in combination with x_log_transformed.

Value

invisible output of lm()

Examples

df <- data.frame(x = 1:10, y = c(1:9, 11))
plot(df$x, df$y)
FunRegressionPlot(x = df$x, y = df$y)

plot(df$x, log(df$y))
FunRegressionPlot(x = df$x, y = log(df$y), y_log_transformed = T)

plot(df$x, log(df$y))
FunRegressionPlot(x = df$x, y = log(df$y), y_log_transformed = T)

retodomax/FunRZ documentation built on July 30, 2023, 6:42 p.m.