[R-sig-eco] Ltraj object without date.end

Michael Sumner mdsumner at gmail.com
Tue Feb 5 06:12:09 CET 2013


It looks to me that there must be a missing value in your date vector.
It's reproducible with a simple example modified from ?as.ltraj:

  data(capreochiz)

     ## Create an object of class "ltraj"
     cap <- as.ltraj(xy = capreochiz[,c("x","y")], date =
c(capreochiz$date[-nrow(capreochiz)], NA),
                     id = "Roe.Deer", typeII = TRUE,
                     infolocs = capreochiz[,4:8])

summary(cap)

        id    burst nb.reloc NAs          date.begin date.end
1 Roe.Deer Roe.Deer     2355   0 2004-02-14 03:02:18     <NA>

So presumably you do have some missing values, perhaps the final lines
in the file are empty rows from Excel? (It's common).

Try any(is.na(Da)) to check.

Cheers, Mike.



On Tue, Feb 5, 2013 at 2:45 PM, John McEvoy <john.mcevoy at deakin.edu.au> wrote:
>
> Hi Folks,
>                I’m having some trouble with creating ltraj objects from irregular GPS data.   I run the same code on two different csv files with identical columns, number formats etc but get two different results.  The only difference between these files are the values of lat/lon and the date-time stamp. I cannot find any extreme values that might be throwing things out. My main problem is that I keep getting ltraj objects with no defined ‘date.end’. Why would this be happening? I hope it’s something simple. Code below.  Thanks for your time,
> John
>
> ##using "as.ltraj" to create a trajectory from GPS data in adehabitatLT
>
> data<-read.csv("Animal_1.csv", na.strings="NA")
>
>
> head(data)
>
> #      ID                Date  Latitude Longitude
> #1 Animal_1 2010-12-12 12:30:00 -30.55900  136.8788
> #2 Animal_1 2010-12-12 14:30:00 -30.55867  136.8788
> #3 Animal_1 2010-12-12 16:30:00 -30.55883  136.8788
> #4 Animal_1 2010-12-12 18:30:00 -30.55883  136.8788
> #5 Animal_1 2010-12-12 20:30:00 -30.55833  136.8790
> #6 Animal_1 2010-12-12 22:30:00 -30.55883  136.8788
>
>
> Da<-strptime(data$Date,format='%Y-%m-%d %H:%M:%S')
>
> Da<-as.POSIXct(Da)
>
> xy<-data[,c("Longitude", "Latitude")]
>
> id<-data$ID
>
> TRAJAnimal_1<-as.ltraj(xy,id,date=Da, burst=id)
>
>
> summary(TRAJAnimal_1)
>
> # id                   burst              nb.reloc   NAs       date.begin            date.end
> #1Animal_1  Animal_1      2169             0    2010-12-12 12:30:00      2011-08-28 08:30:00
>
>
>
>
> ##############################################################################
>
> ##running the same code for another file with the same columns, same formats and i get a trajectory with no "date.end"
>
>
>
> data<-read.csv("Animal_2.csv", na.strings="NA")
>
> head(data)
>
>
> #     ID                Date  Latitude Longitude
> #1 Animal_2 2010-05-15 20:30:00 -33.82517  138.6078
> #2 Animal_2 2010-05-15 22:30:00 -33.82400  138.6085
> #3 Animal_2 2010-05-16 00:30:00 -33.82400  138.6085
> #4 Animal_2 2010-05-16 02:30:00 -33.82400  138.6085
> #5 Animal_2 2010-05-16 04:30:00 -33.82400  138.6085
> #6 Animal_2 2010-05-16 08:30:00 -33.82233  138.6060
>
>
> Da<-strptime(data$Date,format='%Y-%m-%d %H:%M:%S')
>
> Da<-as.POSIXct(Da)
>
> xy<-data[,c("Longitude", "Latitude")]
>
> id<-data$ID
>
> TRAJAnimal_2<-as.ltraj(xy,id,date=Da, burst=id)
>
>
> summary(TRAJAnimal_2)
>
>
>
> #     id                    burst        nb.reloc   NAs          date.begin         date.end
> #Animal_2   Animal_2          2858          0     2010-05-15 20:30:00     <NA>
>
>
> Important Notice: The contents of this email transmission, including any attachments, are intended solely for the named addressee and are confidential and may be subject to legal professional privilege; any unauthorised use, reproduction or storage of the contents and any attachments is expressly prohibited. If you have received this transmission in error, please delete it and any attachments from your system immediately and advise the sender by return email or telephone.  Deakin University does not warrant that this email and any attachments are error or virus free.
>
> Important Notice: The contents of this email are intended solely for the named addressee and are confidential; any unauthorised use, reproduction or storage of the contents is expressly prohibited. If you have received this email in error, please delete it and any attachments immediately and advise the sender by return email or telephone.
>
> Deakin University does not warrant that this email and any attachments are error or virus free.
>
>         [[alternative HTML version deleted]]
>
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>



-- 
Michael Sumner
Hobart, Australia
e-mail: mdsumner at gmail.com



More information about the R-sig-ecology mailing list