Topic: Utilities

Topic Description:

Basic R utilities used in many packages and functions, such as date and string manipulations, statistical distributions, geometry of lines and distances. The R package date is required for the two data functions.



File: utilities/geometry.r

View File Source Download File No help file available

Function: pts.to.interceptslope

Function Description: pts.to.interceptslope

Gets slope and intercept of a line given two pairs of coordinates on the line. If the x's are exactly equal, so slope is infinite, it returns the x as the first argument.

Function Arguments:

ArgumentDefault Value
pt1
pt2

Function Source:

pts.to.interceptslope=function(pt1,pt2)
{
if(pt1$x==pt2$x) return(c(pt1$x,Inf))

m=(pt2$y-pt1$y)/(pt2$x-pt1$x)
b=pt1$y-m*pt1$x

return(c(b,m))
}