I am trying to use the stepacross function in the vegan package of R.
When I do, it throws an error and fails to run the code
Error in stepacross(distance.dat, path = "extended") : object 'C_stepacross' not found
Anybody know the cause of this or what to do to fix it?
I'm using R (64-bit) 4.0.2 and vegan 2.5-6 (old version use is intentional).
It worked a few weeks ago, and I have made no changes since.
The C_stepacross object in question shows up in the stepacross() function code:
getAnywhere(stepacross)
function (dis, path = "shortest", toolong = 1, trace = TRUE,
...)
{
path <- match.arg(path, c("shortest", "extended"))
if (!inherits(dis, "dist"))
dis <- as.dist(dis)
oldatt <- attributes(dis)
n <- attr(dis, "Size")
if (path == "shortest")
dis <- .C(dykstrapath, dist = as.double(dis), n = as.integer(n),
as.double(toolong), as.integer(trace), out = double(length(dis)),
NAOK = TRUE)$out
else dis <- .C(C_stepacross, dis = as.double(dis), as.integer(n),
as.double(toolong), as.integer(trace), NAOK = TRUE)$dis
attributes(dis) <- oldatt
attr(dis, "method") <- paste(attr(dis, "method"),
path)
dis
}
You don't provide a reproducible example, but I can reproduce this problem if I don't use
vegan::stepacross, but a different copy of the function. Check your workspace – it probably has a copy of this function. The C function is registred for use in vegan functions, but not for functions in other namespaces. This example will reproduce your problem:If
getAnyewherefinds first a vegan version ofstepacross, the last line of its output will beIn your example this line was missing suggesting that your copy of
stepacrosswas not innamespace:vegan. Moreover,getAnywhereshould givepackage:veganas the first place where this function was found.