R/locf2func.R

Defines functions locf2func

locf2func <- function(x, ..., maxk = 100) {
    if(!require(locfit))
		stop("can only be used if locfit library is available")
    for(i in 1:10) {
		l <- try(locfit(~x, ..., maxk = i * maxk))
		if(!is(l, "try-error"))
			break;
	}
    den1 <- preplot(l,...)
    xvals <- den1$xev[[1]]
    yvals <- den1$trans(den1$fit)
    f <- function(w) approx(xvals, yvals, w, yleft=0, yright=0)$y
    class(f) <- "dfun"
    f
}

Try the bioDist package in your browser

Any scripts or data that you put into this service are public.

bioDist documentation built on Nov. 8, 2020, 5:14 p.m.