File: regularize.values.R

package info (click to toggle)
r-cran-circular 0.5-1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,492 kB
  • sloc: ansic: 464; fortran: 69; sh: 13; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 632 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
regularize.values <- function (x, y, ties) {
    x <- xy.coords(x, y, setLab = FALSE)
    y <- x$y
    x <- x$x
    if (any(na <- is.na(x) | is.na(y))) {
        ok <- !na
        x <- x[ok]
        y <- y[ok]
    }
    nx <- length(x)
    if (!identical(ties, "ordered")) {
        o <- order(x)
        x <- x[o]
        y <- y[o]
        if (length(ux <- unique(x)) < nx) {
            if (missing(ties)) 
                warning("collapsing to unique 'x' values")
            y <- as.vector(tapply(y, match(x, x), ties))
            x <- ux
            stopifnot(length(y) == length(x))
        }
    }
    list(x = x, y = y)
}