Learn R Programming

gbm.auto (version 2023.06.13)

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

Description

Simple function to plot and name a linear model

Usage

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 = "",
  ...
)

Value

Invisibly saves png plot into 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 &.

Author

Simon Dedman, simondedman@gmail.com

Details

Errors and their origins: