addSLR: Add a Regression Line

View source: R/addSLR.R

addSLRR Documentation

Add a Regression Line

Description

Adds a simple linear regression line to a scatter plot.

Usage

addSLR(x, y, Plot = list(name = "", what = "lines", type = "solid", width
  = "standard", color = "black"), Model = list(x = "", y = "", form =
  "exp", where = "none"), current = list(yaxis.log = FALSE, yaxis.rev =
  FALSE, xaxis.log = FALSE), ...)

## Default S3 method:
addSLR(x, y, Plot = list(name = "", what = "lines",
  type = "solid", width = "standard", color = "black"), Model = list(x =
  "", y = "", form = "exp", where = "none"), current = list(yaxis.log =
  FALSE, yaxis.rev = FALSE, xaxis.log = FALSE), ...)

## S3 method for class 'list'
addSLR(x, y, Plot = list(name = "", what = "lines", type =
  "solid", width = "standard", color = "black"), Model = list(x = "", y =
  "", form = "exp", where = "none"), current = list(yaxis.log = FALSE,
  yaxis.rev = FALSE, xaxis.log = FALSE), ...)

Arguments

x

the x-axis data. For method list, x is a list that contains components x and y and the y argument is not used. Missing values are permitted but omitted in the regression.

y

the y-axis data. Missing values are permitted but omitted.

Plot

parameters defining the characteristics of the plot. See setPlot for a description of the parameters.

Model

parameters for displaying the simple linear regression model. See Details.

current

the current plot information. Typically, this would be the output from one of the graph creation functions like xyPlot.

...

not used, required for other methods.

Details

The Model argument sets up the information to include the regression model equation on the graphs. Within Model, x is the name to use for the explanatory variable, y is the name to use for the response variable, form indicates the form that the regression model should take if the variable are log transformed; "exp" indicates that the model equation should be expressed as an exponent, any other string indicates thet the model should be expressed using the transformation functions; and where indicates where to place the equation. The value for where is a two letter code based on "upper," "center," or "lower" and "right," "center," or "left"—for example "ul" would place the model equaiton in the upper left corner.

Value

The current plot information, the x and y components are the data, not the line. The regression model is included as the lm component.

See Also

addXY, xyPlot

Examples

## Not run: 
set.seed(1)
X <- rnorm(32)
Y <- X + rnorm(32)
setGD()
AA.pl <- xyPlot(X, Y)
addSLR(AA.pl)
# For more details of addSLR see
vignette(topic="GraphAdditions", package="smwrGraphs")

## End(Not run)

USGS-R/smwrGraphs documentation built on Oct. 11, 2022, 6:11 a.m.