Reputation: 21
I am having a reoccuring error with the move package, where I cannot use the distance
function. When I first load the package, I am given the warning
"multiple methods tables found for ‘distance’".
Later, when following the move vignette, I run the line of code:
distance(leroy)[1:5]
and am given the error:
"Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘distance’ for signature ‘"Move", "missing"’".
In applying this code to my own dataset, I receive the same error. I assumed this was because R was using a different package for 'distance', however when I directly call it through move::distance(leroy)
or even terra::distance(leroy)
I still receive the same error. I have tried reinstalling the package and the 'terra' and 'raster' packages that move requires; my laptop (Mac), RStudio, and all other packages are updated. Gdal is updates, along with geos and proj. I have run the code on a different laptop, as well as on rdrr.io, and it runs perfectly there, so I am assuming the issue is with my laptop. ?move::distance()
shows me the function description, where x is a move, movestack, or moveburst object. Both the dataset 'leroy' downloaded from Movebank and my own dataset are move objects. Has anyone else run in to a similar problem or have any troubleshooting suggestions?
Upvotes: 1
Views: 302
Reputation: 21
Solved!
The move package has not updated to account for raster now requiring terra. I downloaded the move package source from CRAN (move_4.0.6.tar.gz) and ran their code for the distance function after loading the move package in to R. The code for their distance method is:
#setGeneric("distance")#, function(x){standardGeneric("distance")})
setMethod("distance",
signature=c(x=".MoveTrackSingle",y="missing"),
definition=function(x){
Dists<-raster::pointDistance(x[-sum(n.locs(x)),], x[-1,], longlat=isLonLat(x))
return(Dists)
})
setMethod("distance",
signature=c(".MoveTrackStack",y="missing"),
definition=function(x){
lst <- lapply(split(x), distance)
return(lst)
})
Upvotes: 1