Learn R Programming

WVPlots (version 1.1.1)

ConditionalSmoothedScatterPlot: Plot a scatter plot with smoothing line.

Description

Plot a scatter plot with a smoothing line; the smoothing window is aligned either left, center or right.

Usage

ConditionalSmoothedScatterPlot(frame, xvar, yvar, groupvar, title, ...,
  k = 3, align = "center")

Arguments

frame

data frame to get values from

xvar

name of the independent column in frame. Assumed to be regularly spaced

yvar

name of the dependent (output or result to be modeled) column in frame

groupvar

name of the grouping column in frame. Can be NULL for an unconditional plot

title

title for plot

...

no unnamed argument, added to force named binding of later arguments.

k

width of smoothing window. Must be odd for a center-aligned plot. Defaults to 3

align

smoothing window alignment: 'center', 'left', or 'right'. Defaults to 'center'

Details

xvar is the continuous independent variable and yvar is the dependent binary variable. Smoothing is by a square window of width k.

Examples

Run this code
# NOT RUN {
y = c(1,2,3,4,5,10,15,18,20,25)
x = seq_len(length(y))
df = data.frame(x=x, y=y, group=x>5)
WVPlots::ConditionalSmoothedScatterPlot(df, "x", "y", NULL,
   title="left smooth, one groups", align="left")
WVPlots::ConditionalSmoothedScatterPlot(df, "x", "y", "group",
   title="left smooth, two groups", align="left")

# }

Run the code above in your browser using DataLab