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/statistics.r

View File Source Download File No help file available

Function: majoraxisreg

Function Description: majoraxisreg

A major axis regression with parameters fitted by optim. The regression is the line which minimizes perpendicular distance summed over all points (and squared).

Function Arguments:

ArgumentDefault Value
x
y
title""
graphitF
addF
ptsT
clr"blue"
xtitle"x"
ytitle"y"
ptsize1
labsize1

Function Source:


majoraxisreg=function(x,y,title="",graphit=F,add=F,pts=T,clr="blue",xtitle="x",ytitle="y",ptsize=1,l
        absize=1) {
start.param=c(1,1)

fit=optim(start.param,minum.perpdist,x=x,y=y)
m=fit$par[2]
b=fit$par[1]

if(graphit)
{
if(add & pts) points(x,y,pch=16)

if(!add & pts) plot(x,y,pch=16,main=title,xlab=xtitle,ylab=ytitle,cex=ptsize,cex.lab=labsize,cex.
        axis=labsize) abline(b,m,col=clr)
}

return(fit$par)
}