lmEqn: Plot Points, Fit a Line, Display Equation

View source: R/lmEqn.R

lmEqnR Documentation

Plot Points, Fit a Line, Display Equation

Description

This function plots the points given, then fits a line and displays the regression statistics using lattice.

Usage

lmEqn(
  formula = NULL,
  data = NULL,
  method = "lm",
  leg.loc = c(0.5, 0.5),
  theme = screenTheme(),
  ...
)

Arguments

formula

A formula with both LHS and RHS. The formula should comply with the usual R standards, for instance y ~ x.

data

A data frame containing two columns whose names correspond to the specified formula.

method

A character string. Either "lm" for linear model or "rlm" for a robust fit.

leg.loc

A vector of two numbers (x, y) giving the location of the legend. The values correspond to the units of the data. See the examples.

theme

Character; A suitble lattice theme. There are two built-in themes which you can use "as is" or modify to your heart's content. If none is given, screenTheme will be used. The other option provided is posterTheme.

...

Additional arguments to be passed downstream.

Value

A plot is drawn and the ggplot2 or lattice object is returned, possibly for further manipulation.

Author(s)

Bryan A. Hanson, DePauw University. hanson@depauw.edu

Examples


require("lattice")
require("latticeExtra")
require("plyr")
require("MASS")

conc = seq(1, 12, length.out = 8)
abs = jitter(conc, factor = 2)*0.1
cc <- data.frame(conc, abs)
lmEqn(formula = abs ~ conc, data = cc, method = "rlm",
leg.loc = c(3, 0.1),
xlab = "concentration", ylab = "absorbance",
main = "Calibration Curve")


bryanhanson/HandyStuff documentation built on July 22, 2022, 6:18 a.m.