add_line: Add a line to an 'xyplot'

View source: R/add_line.R

add_lineR Documentation

Add a line to an xyplot

Description

Include a line to an xyplot by either including a slope and intercept term or by clicking twice on the Plots pane in RStudio. After creating an xyplot, either run add_line() with no arguments and then click on the RStudio plot plane twice to draw a line OR include arguments for slope and intercept to draw a specific line.

Usage

add_line(
  intercept,
  slope,
  vline = NULL,
  hline = NULL,
  units = "native",
  color = "red"
)

Arguments

intercept

Numerical (optional). The intercept term for a line to plot.

slope

color (optional). Sets color of the line to be drawn

See Also

add_curve

Examples

data(cdc)

## Not run: 
# Add a line by clicking on the plot pane
xyplot(weight ~ height, data = cdc)
add_line() # Click the Plots pane twice inorder to proceed.

## End(Not run)

# Specify a line using the slope and intercept arguments
xyplot(weight ~ height, data = cdc)
add_line(intercept = -180, slope = 165)

# Include a horizontal and/or vertical line
xyplot(weight ~ height, data = cdc)
add_line(vline = 1.6, hline = 100)


mobilizingcs/mobilizr documentation built on Feb. 17, 2024, 7:49 p.m.