plotLine: X-Y Plotting with Simple Linear Regression Line and Equation

Description Usage Arguments Note Author(s) See Also Examples

Description

The function plots a simple scatter plot, fits the regression line on the scatter plot, and lists the equation of the fitted regression line as the title.

Usage

1
2
plotLine(x, y = NULL, data = NULL, xlab = NULL, ylab = NULL, pch = 19, 
         col = c("black", "red"), digits.intercept = NULL, digits.slope = NULL, ...)

Arguments

x

The x coordinates of points in the plot. Alternatively, a single plotting structure or function can be provided.

y

The y coordinates of points in the plot, optional if x is an appropriate structure.

data

A data frame including the x and y coordinates.

xlab

The label of the x variable.

ylab

The label of the y variable.

pch

The plotting character; i.e., symbol to use. This can be either a single character or an integer code for one of a set of graphics symbols.

col

A vector of size two for the color code or name. The first value is the color of the plotting character, and the second value is the color of the fitted regression line.

digits.intercept

The desired number of significant digits for the intercept.

digits.slope

The desired number of significant digits for the slope.

...

Optional arguments to be passed to the plot function (see par).

Note

This function plotLine uses functions plot and lm.

Author(s)

Steven T. Garren, James Madison University, Harrisonburg, Virginia, USA

See Also

plot and lm

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
par( mfrow=c(2,2) )

x = c( 2, 6, 5, -3, 11, 3 ) ;  y = c( 16, 12, 19, -13, 27, 5 )

plotLine( x, y )

plotLine( x, -y, col=c("red", "green"), digits.intercept=2, digits.slope=3 )

d = data.frame( x=c( 2, 7, 9, 15, 12 ), y=c( 45, 32, 22, 15, 19 ) )

plotLine( y~x, data=d, col=c("blue","orange") )

plotLine( y~x, data=d, xlab="TIME", ylab="EXPENSE", digits.intercept=3, digits.slope=4 )

par( mfrow=c(1,1) )

Example output



fastGraph documentation built on July 23, 2019, 5:04 p.m.