I am running the script from de Distance examples (http://examples.distancesampling.org/Distance-cues/cuecounts-distill.html) to estimate density using function dht2 of Distance library but I have an error.

The script is:

library (Distance)
conversion.factor <- convert_units("meter", NULL, "hectare")
wren_cuecount$Effort <- wren_cuecount$Search.time
wrensong.hr <- ds(wren_cuecount, transect="point", key="hr", adjustment=NULL, 
cuerate <- unique(wren_cuecount[ , c("Cue.rate","Cue.rate.SE")])
names(cuerate) <- c("rate", "SE")
(mult <- list(creation=cuerate))
wren.estimate <- dht2(wrensong.hr, flatfile=wren_cuecount, strat_formula=~1,
                      multipliers=mult, convert_units=conversion.factor)
print(wren.estimate, report="density")""

When I run the dht2 function I get:

Error in apply(grps, 1, function(x) any(is.na(x))) : dim(X) must have a positive length

How can I solve this?

  • $\begingroup$ Please format your code so that it can be understood. $\endgroup$
    – acvill
    Oct 22 '21 at 19:46
  • $\begingroup$ Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. $\endgroup$
    – Community Bot
    Oct 23 '21 at 14:40
  • $\begingroup$ I would suggest inspecting some of the intermediate objects such as wrengsong.hr, wren_cuecount, mult, etc. to ensure that they match the expected inputs of those functions. $\endgroup$ Oct 25 '21 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.