brk2midp {lazy.tools} R Documentation

## Define Midpoints from Break Points

### Description

Define Midpoints from Break Points

### Usage

```brk2midp(brk, min = NULL)
```

### Arguments

 `brk` a vector of break points. `min` The value of the lowest midpoint. This has priority over margin.

### Details

Break values from midpoint values:
`brk=midp - margin`
`brk=midp + (midp-midp)/2`
`brk=midp + (midp-midp)/2`
`brk[length(midpoints)+1]=midp[length(midpoints)] + margin`
where `margin=(midp-midp)/2`.
In general, the break point is located at the center of two midpoints:
`brk[k]=0.5*(midp[k-1]+midp[k])`

Midpoint values from break values:
`midp=0.5*(brk+brk)` or midp=min
`midp=0.5*(brk+brk)`
`midp=2*brk-midp`
`brk[length(brk)-1]=2*brk[length(brk)-1]-midp[length(brk)-2]`

Note that midp is treated separately and it is assumed that the break point is located at the center of two midpoints.

Try below to see how the obs on the border are classified.
` xx <- c(1,2,3,4,5,6,7) `
` brks <- c(0,2,4,6,8) `
` cc1 <- cut(xx,brks) `
` cc2 <- cut(xx,brks, right=FALSE) `
` Print(xx,as.character(cc1),as.character(cc2)) `

### Value

A vector of midpoints of length length(brk)-1.

### Examples

```midp <- c(0,1,2,4,6,9,10,11)
brk <- midp2brk( midp )
Print( midp, brk, brk2midp(brk) )
brk <- -4
Print( midp, brk, brk2midp(brk) )

```

[Package lazy.tools version 0.1.3 Index]