I got around my problem by using this version of the code:
mindistkeep2 <- function(x, threshold)
{
    if (!inherits(x,"ltraj"))
        stop("x should be of class 'ltraj'")
    foo <- function(y) {
        ul <- 1
        if (nrow(y) > 2){######## skip for small burst
                for (i in 2:nrow(y)) {
                        if(y$dist[i-1]<threshold){
                                ul[i]= ul[i-1]
                                y$dist[i] = sqrt( (y$x[i+1] -y$x 
[ul[i]])*(y$x[i+1] -y$x [ul[i]])+(y$y[i+1]
-y$y [ul[i]])*(y$y[i+1] -y$y [ul[i]]) )##recalculate the distance from the first
point
                        } else ul[i]={i}
                }
        }
        if (!is.null(attr(y, "infolocs"))) {
            infol <- attr(y, "infolocs")
        }
        z <- y[ul,c("x","y")]
        da <- y$date
        if (!is.null(attr(y, "infolocs"))) {
            infol <- attr(y, "infolocs")
            lt <- as.ltraj(z, da, id=attr(y,"id"), burst=attr(y,"burst"),
                           typeII=attr(x,"typeII"), infolocs=infol)
        } else {
            lt <- as.ltraj(z, da, id=attr(y,"id"), burst=attr(y,"burst"),
                           typeII=attr(x,"typeII"))
        }
        return(lt)
    }
    res <- do.call("c.ltraj", lapply(x, foo))
    class(res) <- c("ltraj","list")
    return(res)
}


Feel free to add it (or a corrected version if there are mistakes) in the next
version of adehabitat (I also added a piece of code to avoid errors on very
short bursts).

thanks for all your work
julien



_______________________________________________
AniMov mailing list
AniMov@faunalia.it
http://lists.faunalia.it/cgi-bin/mailman/listinfo/animov

Reply via email to