R/speed.R

setGeneric("speed", function(x) {
  standardGeneric("speed")
})
setMethod("speed",
  signature = ".MoveTrackSingle",
  definition = function(x) {
    # if(length(seglength(x)>0)){
    Speed <- (distance(x)) / timeLag(x, units = "secs") # meter per sec
    return(Speed) # } else {return(NA)}
  }
)

setMethod("speed",
  signature = ".MoveTrackStack",
  definition = function(x) {
    lst <- lapply(split(x), speed)
    return(lst)
  }
)

Try the move package in your browser

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

move documentation built on July 9, 2023, 6:09 p.m.