scatter: Scatter Plot with Lowess Curves

Description Usage Arguments Value Author(s) Examples

Description

Produces a scatter plot of two variables with (possibly stratified) superimposed lowess smooths and least squares fitted lines.

Usage

1
2
3
4
5
 scatter(y, x, strata=rep(1,length(y)), subset= rep(TRUE,length(y)), 
 reference=sort(unique(strata)), plotPoints=TRUE, plotLowess=TRUE, plotLSfit=FALSE, 
 legend=0.05, colors=c("black", "blue", "orange", "pink", "green", "red", 
 "cornflowerblue", "darkolivegreen", "magenta"), xJitter=TRUE, yJitter=FALSE, 
 newplot=TRUE, lty=1:6, lwd=1, log="",pch=1:25, ..., version=FALSE) 

Arguments

y

a numeric vector containing the values to be plotted on the y-axis.

x

a numeric vector containing the values to be plotted on the x-axis.

strata

a vector, matrix, or list of stratification variables. Descriptive statistics will be computed within strata defined by each unique combination of the stratification variables, as well as in the combined sample. If strata is supplied, all variables must be of that same length.

subset

a vector indicating a subset to be used for all descriptive statistics. If subset is supplied, all variables must be of that same length.

reference

a list of the strata in the order they are to be plotted.

plotPoints

an indicator that points are to be plotted. A different color and point type combination will be used for each stratum. Default value is TRUE.

plotLowess

an indicator that lowess smoths are to be plotted. A different color and line type combination will be used for each stratum. Default value is TRUE.

plotLSfit

an indicator that least squares fitted lines are to be plotted. A different color and line type combination will be used for each stratum. Default value is TRUE.

legend

where to place the legend on the plot

colors

a vector of colors used in plotting strata.

xJitter

the proportion of the minimal difference between adjacent x-values divided by 8 by which plotted points are to be jittered in the x-dimension. A value of 0 implies no jittering.

yJitter

the proportion of the minimal difference between adjacent y-values divided by 8 by which plotted points are to be jittered in the y-dimension. A value of 0 implies no jittering.

newplot

logical value indicating that the graph should be plotted on a new set of axes. Default value is TRUE.

lty, lwd, log,pch

plotting parameters.

...

optional arguments for plotting parameters (e.g. xlab, ylab, main) that will be passed to plot().

version

if TRUE, the version of the function will be returned. No other computations will be performed.

Value

This function produces a plot. No value is returned.

Author(s)

Scott S. Emerson, M.D., Ph.D., Andrew J. Spieker, Brian D. Williamson, Travis Y. Hee Wai, and Solomon Lim

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#- Read in and attach the data -#
mri <- read.table("http://www.emersonstatistics.com/datasets/mri.txt", header=TRUE)
attach(mri)

#- Create a scatterplot with lowess curves and least squares fitted regression lines -#
scatter(atrophy, age, ylab="Atrophy", xlab="Age")

#- Create a scatterplot stratified by age on the log scale with lowess curves and -#
#- least squares fitted regression lines -#
scatter(atrophy, age, strata=male,ylab="Atrophy", xlab="Age",log="y")

uwIntroStats documentation built on May 2, 2019, 4:34 a.m.