Running examples in 'mrds-Ex.R' failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: ddf
> ### Title: Distance Detection Function Fitting
> ### Aliases: ddf
> ### Keywords: Models ~Statistical
> 
> ### ** Examples
> 
> # load data
> data(book.tee.data)
> region <- book.tee.data$book.tee.region
> egdata <- book.tee.data$book.tee.dataframe
> samples <- book.tee.data$book.tee.samples
> obs <- book.tee.data$book.tee.obs
> 
> # fit a half-normal detection function
> result <- ddf(dsmodel=~mcds(key="hn", formula=~1), data=egdata, method="ds",
+               meta.data=list(width=4))
Warning in if (class(nhatend) != "try-error") { :
  the condition has length > 1 and only the first element will be used
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
mrds
 --- call from context --- 
ddf.ds(model = dsmodel, data, meta.data = meta.data, control = control, 
    call = match.call())
 --- call from argument --- 
if (class(result$hessian) == "try-error") {
    if (misc.options$mono) {
        warning("First partial hessian calculation failed with monotonicity enforced, no hessian\n")
    }
    else {
        warning("First partial hessian calculation failed; using second-partial hessian\n")
        result$hessian <- lt$hessian
    }
} else if (length(lt$par) > 1) {
    if (class(try(solve(result$hessian), silent = TRUE)) == "try-error") {
        warning("First partial hessian is singular; using second-partial hessian\n")
        result$hessian <- lt$hessian
    }
}
 --- R stacktrace ---
where 1: ddf.ds(model = dsmodel, data, meta.data = meta.data, control = control, 
    call = match.call())
where 2: ddf(dsmodel = ~mcds(key = "hn", formula = ~1), data = egdata, 
    method = "ds", meta.data = list(width = 4))

 --- value of length: 2 type: logical ---
[1] FALSE FALSE
 --- function from context --- 
function (model, data, meta.data = list(), control = list(), 
    call, method = "ds") 
{
    if (!is.null(meta.data$mono.strict)) {
        if (meta.data$mono.strict) {
            meta.data$mono <- TRUE
        }
    }
    if (!is.null(meta.data$mono)) {
        if (meta.data$mono & is.null(meta.data$mono.strict)) {
            meta.data$mono <- TRUE
        }
    }
    meta.data <- assign.default.values(meta.data, left = 0, width = NA, 
        binned = FALSE, int.range = NA, mono = FALSE, mono.strict = FALSE, 
        point = FALSE)
    control <- assign.default.values(control, showit = 0, estimate = TRUE, 
        refit = TRUE, nrefits = 25, initial = NA, lowerbounds = NA, 
        upperbounds = NA, limit = TRUE, parscale = TRUE, maxiter = 12, 
        standardize = TRUE, mono.points = 20, mono.tol = 1e-08, 
        mono.delta = 1e-07, debug = FALSE, nofit = FALSE, optimx.method = "nlminb", 
        optimx.maxit = 300, silent = FALSE)
    save.options <- options()
    options(contrasts = c("contr.treatment", "contr.poly"))
    if (!is.null(data$distance)) {
        data <- data[!is.na(data$distance), ]
    }
    else {
        data <- data[!is.na(data$distbegin) & !is.na(data$distend), 
            ]
    }
    if (is.null(data$object)) {
        stop("\nobject field is missing in the data\n")
    }
    datalist <- process.data(data, meta.data, check = FALSE)
    xmat <- datalist$xmat
    meta.data <- datalist$meta.data
    if (!is.null(xmat$observer)) {
        if (control$limit) {
            if (length(levels(factor(xmat$observer))) > 1) {
                xmat <- xmat[xmat$observer == levels(factor(xmat$observer))[1], 
                  ]
                xmat$detected <- rep(1, dim(xmat)[1])
            }
        }
    }
    if (!is.null(xmat$detected)) {
        if (control$limit) 
            xmat <- xmat[xmat$detected == 1, ]
    }
    else {
        xmat$detected <- rep(1, dim(xmat)[1])
    }
    if (length(unique(xmat$object)) != length(xmat$object)) {
        stop("\nSome values of object field are duplicates. They must be unique.\n")
    }
    if (meta.data$binned) {
        breaks <- c(max(0, min(as.numeric(levels(as.factor(xmat$distbegin))))), 
            as.numeric(levels(as.factor(xmat$distend))))
    }
    else {
        breaks <- NULL
    }
    ddfobj <- create.ddfobj(model, xmat, meta.data, control$initial)
    initialvalues <- c(ddfobj$shape$parameters, ddfobj$scale$parameters, 
        ddfobj$adjustment$parameters)
    if (!is.null(initialvalues)) {
        bounds <- setbounds(control$lowerbounds, control$upperbounds, 
            initialvalues, ddfobj)
    }
    else {
        bounds <- NULL
    }
    misc.options <- list(point = meta.data$point, int.range = meta.data$int.range, 
        showit = control$showit, integral.numeric = control$integral.numeric, 
        breaks = breaks, maxiter = control$maxiter, refit = control$refit, 
        nrefits = control$nrefits, parscale = control$parscale, 
        mono = meta.data$mono, mono.strict = meta.data$mono.strict, 
        binned = meta.data$binned, width = meta.data$width, standardize = control$standardize, 
        mono.points = control$mono.points, mono.tol = control$mono.tol, 
        mono.delta = control$mono.delta, debug = control$debug, 
        nofit = control$nofit, left = meta.data$left, silent = control$silent)
    if (misc.options$showit >= 1 && !is.null(initialvalues)) {
        cat("DEBUG: initial values =", round(initialvalues, 7), 
            "\n")
    }
    optim.options <- list(maxit = control$optimx.maxit, optimx.method = control$optimx.method, 
        parscale = control$parscale)
    if (is.null(initialvalues)) 
        misc.options$nofit <- TRUE
    lt <- detfct.fit(ddfobj, optim.options, bounds, misc.options)
    stored_data <- data[row.names(data) %in% row.names(xmat), 
        ]
    stored_data$detected <- 1
    result <- list(call = call, data = stored_data, model = substitute(model), 
        meta.data = meta.data, control = control, method = method, 
        ds = lt, par = lt$par, lnl = -lt$value)
    if (lt$converge != 0 & misc.options$debug) {
        warning("No convergence, not calculating Hessian, predicted values, abundance\nReturned object is for debugging ONLY!")
        options(save.options)
        return(result)
    }
    if (is.null(lt$par)) {
        lt$hessian <- NULL
    }
    else {
        result$hessian <- try(flt.var(result$ds$aux$ddfobj, misc.options))
        if (class(result$hessian) == "try-error") {
            if (misc.options$mono) {
                warning("First partial hessian calculation failed with monotonicity enforced, no hessian\n")
            }
            else {
                warning("First partial hessian calculation failed; using second-partial hessian\n")
                result$hessian <- lt$hessian
            }
        }
        else if (length(lt$par) > 1) {
            if (class(try(solve(result$hessian), silent = TRUE)) == 
                "try-error") {
                warning("First partial hessian is singular; using second-partial hessian\n")
                result$hessian <- lt$hessian
            }
        }
    }
    modpaste <- paste(model)
    modelvalues <- try(eval(parse(text = modpaste[2:length(modpaste)])))
    class(result$ds) <- c(modelvalues$fct, "ds")
    result$dsmodel <- modpaste
    n <- length(xmat$distance)
    npar <- length(lt$par)
    result$criterion <- 2 * lt$value + 2 * npar
    class(result) <- c("ds", "ddf")
    if (!is.null(ddfobj$adjustment) & (ddfobj$type %in% c("hn", 
        "hr", "unif"))) {
        result$monotonicity.check <- check.mono(result, n.pts = control$mono.points)
    }
    if (is.null(lt$message)) {
        result$ds$message <- ""
    }
    if (lt$message == "FALSE CONVERGENCE") {
        warning("Model fitting did not converge. Try different initial values or different model")
    }
    else {
        result$fitted <- predict(result, esw = FALSE)$fitted
        if (control$estimate) {
            result$Nhat <- NCovered(result, group = TRUE)
        }
    }
    options(save.options)
    return(result)
}
<bytecode: 0xc2ee918>
<environment: namespace:mrds>
 --- function search by body ---
Function ddf.ds in namespace mrds has this body.
 ----------- END OF FAILURE REPORT -------------- 
Error in if (class(result$hessian) == "try-error") { : 
  the condition has length > 1
Calls: ddf -> ddf.ds
Execution halted