lmplot function

Plot linear model for two variables with R2 & P printed and saved

Plot linear model for two variables with R2 & P printed and saved

Simple function to plot and name a linear model

lmplot( x, y, xname = "X variable", yname = "Y variable", pngtype = c("cairo-png", "quartz", "Xlib"), xlab = xname, ylab = yname, plotname = xname, r2line = TRUE, pointtext = FALSE, pointlabs = x, pointcol = "black", savedir = "", ... )

Arguments

  • x: Explanatory variable data.
  • y: Response variable data.
  • xname: Variable name for plot header.
  • yname: Variable name for plot header.
  • pngtype: Filetype for png files, alternatively try "quartz" on Mac.
  • xlab: X axis label, parsed from xname unless specified.
  • ylab: Y axis label, parsed from yname unless specified.
  • plotname: Filename for png, parsed from xname unless specified.
  • r2line: Plot rsquared trendline, default TRUE.
  • pointtext: Label each point? Default FALSE.
  • pointlabs: Point labels, defaults to resvar value.
  • pointcol: Points colour, default "black".
  • savedir: Save location, end with "/".
  • ...: Allows controlling of text label params e.g. adj cex &.

Returns

Invisibly saves png plot into savedir.

Details

Errors and their origins:

Author(s)

Simon Dedman, simondedman@gmail.com

  • Maintainer: Simon Dedman
  • License: MIT + file LICENSE
  • Last published: 2024-10-01

Useful links