% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/midp2brk.R
\name{brk2midp}
\alias{brk2midp}
\title{Define Midpoints from Break Points}
\usage{
brk2midp(brk, min = NULL)
}
\arguments{
\item{brk}{a vector of break points.}

\item{min}{The value of the lowest midpoint.
This has priority over margin.}
}
\value{
A vector of midpoints of length length(brk)-1.
}
\description{
Define Midpoints from Break Points
}
\details{
Break values from midpoint values: \cr
 \code{brk[1]=midp[1] - margin}\cr
 \code{brk[2]=midp[1] + (midp[2]-midp[1])/2} \cr
 \code{brk[3]=midp[2] + (midp[3]-midp[2])/2} \cr
 \code{brk[length(midpoints)+1]=midp[length(midpoints)] + margin} \cr
 where \code{margin=(midp[2]-midp[1])/2}. \cr
 In general, the break point is located at the center of two midpoints:\cr
 \code{brk[k]=0.5*(midp[k-1]+midp[k])}
 \cr

Midpoint values from break values: \cr
 \code{midp[1]=0.5*(brk[1]+brk[2])} or {midp[1]=min}\cr
 \code{midp[2]=0.5*(brk[2]+brk[3])} \cr
 \code{midp[3]=2*brk[3]-midp[2]} \cr
 \code{brk[length(brk)-1]=2*brk[length(brk)-1]-midp[length(brk)-2]} \cr
\cr
Note that midp[1] is treated separately and it is assumed that
the break point is located at the center of two midpoints.
\cr\cr
Try below to see how the obs on the border are classified. \cr
   \code{ xx <- c(1,2,3,4,5,6,7) } \cr
   \code{ brks <- c(0,2,4,6,8) } \cr
   \code{ cc1 <- cut(xx,brks) } \cr
   \code{ cc2 <- cut(xx,brks, right=FALSE) } \cr
   \code{ Print(xx,as.character(cc1),as.character(cc2)) }\cr
}
\examples{
midp <- c(0,1,2,4,6,9,10,11)
brk <- midp2brk( midp )
Print( midp, brk, brk2midp(brk) )
brk[1] <- -4
Print( midp, brk, brk2midp(brk) )

}
