Description Usage Arguments Value Author(s) See Also Examples
Generate arguments to plot a line via abline
.
1 | ab(p1, p2)
|
p1 |
first point |
p2 |
second point |
A list with suitable named arguments for abline
v |
For a horizontal line |
a, b |
intercept and slope |
Georges Monette
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function( p1, p2 ) {
# prepare arguments to plot a line with
# do.call('abline', ab( p1, p2))
d <- p2 - p1
if ( d[1] == 0) {
ret <- list( v = p1[1])
}
else {
b = (p2[2]-p1[2])/(p2[1]-p1[1])
ret <- list( a = p2[2] - b*p2[1], b =b)
}
ret
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.