Learn R Programming

spp (version 1.16.0)

densum: Do Something

Description

Densum

Usage

densum(vin, bw = 5, dw = 3, match.wt.f = NULL, return.x = T,
       from = min(vin), to = max(vin), step = 1, new.code = T)

Arguments

vin

Parameter

bw

Parameter

dw

Parameter

match.wt.f

Parameter

return.x

Parameter

from

Parameter

to

Parameter

step

Parameter

new.code

Parameter

Value

Some sum

Examples

Run this code
# NOT RUN {
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (vin, bw = 5, dw = 3, match.wt.f = NULL, return.x = T, 
    from = min(vin), to = max(vin), step = 1, new.code = T) 
{
    tc <- table(vin[vin >= from & vin <= to])
    pos <- as.numeric(names(tc))
    storage.mode(pos) <- "double"
    tc <- as.numeric(tc)
    storage.mode(tc) <- "double"
    n <- length(pos)
    if (!is.null(match.wt.f)) {
        tc <- tc * match.wt.f(pos)
    }
    rng <- c(from, to)
    if (rng[1] < 0) {
        stop("range extends into negative values")
    }
    if (range(pos)[1] < 0) {
        stop("position vector contains negative values")
    }
    storage.mode(n) <- storage.mode(rng) <- storage.mode(bw)
          <- storage.mode(dw) <- storage.mode(step) <- "integer"
    spos <- rng[1]
    storage.mode(spos) <- "double"
    dlength <- floor((rng[2] - rng[1])/step) + 1
    if (dlength < 1) {
        stop("zero data range")
    }
    if (new.code) {
        storage.mode(step) <- storage.mode(dlength)
              <- storage.mode(bw) <- storage.mode(dw) <- "integer"
        dout <- .Call("ccdensum", pos, tc, spos, bw, dw, dlength, 
            step)
    }
    else {
        dout <- numeric(dlength)
        storage.mode(dout) <- "double"
        storage.mode(dlength) <- "integer"
        .C("cdensum", n, pos, tc, spos, bw, dw, dlength, step, 
            dout)
    }
    if (return.x) {
        return(list(x = c(rng[1], rng[1] + step * (dlength - 
            1)), y = dout, step = step))
    }
    else {
        return(dout)
    }
  }
# }

Run the code above in your browser using DataLab