Dear Animov list,
I have another question for the list that I haven't been able to resolve. I am
trying to make my data into a regular trajectory and the sett0 and setNA
commands don't seem to be setting the tolerance (tol) levels as they are
supposed to. Or I don't know what I am doing, which is more likely:).
I have data collected every 15 minutes, but since it was collected by hand the
data wasn't always collected exactly at the 15 minute interval. Sometimes it
was even collected quite a while after the 15 minute interval. I would like to
round the data to the nearest 15 minutes, but only if the data was collected
within two minutes of the 15 minute mark. If it was over/under 2 minutes from
the interval, then it should be NA.
For example:
#Trajectory variables
x<-c(808993.9,809172.2,809271.6,809284.6 ,809552.3,809364.3)
y<-c(2189323,2189721,2190037,2190296,2190984,2191737)
xy<-data.frame(x,y)
names(xy)<-c("Long.utm","Lat.utm")
id<-as.character(rep("Test",6))
da<-as.POSIXct(c("2009-07-31 13:29:00", "2009-07-31 13:31:30", "2009-07-31
13:49:00", "2009-07-31 14:00:00","2009-07-31 14:15:00", "2009-07-31 14:45:00"))
#Create type II trajectory
t1<- as.ltraj(xy,id=id,date=da)
#Add NA's to missing values
refda <- strptime("00:00", "%H:%M")
t2 <- setNA(t1, refda, dt=15, units = "min")
#Round values to nearest quarter hour if they are within two minutes of quarter
t3<-sett0(t2, refda, dt=15,tol=2, units = "min")
#Results
t1[[1]]
t2[[1]]
t3[[1]]
As I understand it, the tol level determines how close the date value should be
to dt. However, in my example I have a time of 13:49 which is 4 minutes from
13:45. This should return NA in my thinking, not be rounded down to 13:45.
Also, the first value returned should have been the 13:29 data since it is
closer to 13:30 than the 13:31:30 data. I would appreciate your help in
explaining "tol" and how to set limits for my data. Please cc
mudiver1...@yahoo in your reply. Otherwise my browser won't let me respond to
the thread.
Thanks,
Tim
Tim Clark
Department of Zoology
University of Hawaii
_______________________________________________
AniMov mailing list
[email protected]
http://lists.faunalia.it/cgi-bin/mailman/listinfo/animov