Hello Mike,

I have radio tracking data involving relocations of raccoons over the course
of a night (locations every 20 minutes).  I have the date and time of each
location.  I am trying to convert the data into an type II ltraj so I can do
a first passage time analysis.  My problem is that when I try to create the
ltraj I get the following error message
Error in as.ltraj(xy, da, id) : date should be of the same length as xy


Does anybody know why I get this message/what it means/how to fix it? Here
is the code I that I have used so far

data1<- read.csv(file.choose())
xy <- data1[,c("X","Y")]
da <- as.character(data1$Time)
da <- as.POSIXct(strptime(as.character(data1$Time),"%m/%d/%y%H:%M:%S"))
id <- as.character(data1$id)
data1 <- as.ltraj(xy, da, id)
Error in as.ltraj(xy, da, id) : date should be of the same length as xy

If anybody could help me get through this I would greatly appreciate it.

The message means that the number of rows differ from the length of da, but it is hard to know why without more detail about your data. For example, it may be that you misspelled the names of your variables (data1$Time instead of data1$time, etc.). There are many possibilities, so it would help if you could show us what is in your data at each step, i.e. the result of the following command:

head(data1)
xy <- data1[,c("X","Y")]
head(xy)
da <- as.character(data1$Time)
head(da)
da <- as.POSIXct(strptime(as.character(data1$Time),"%m/%d/%y%H:%M:%S"))
head(da)
id <- as.character(data1$id)
head(id)
data1 <- as.ltraj(xy, da, id)


Regards,

Clément Calenge

--
Clément CALENGE
Office national de la chasse et de la faune sauvage
Saint Benoist - 78610 Auffargis
tel. (33) 01.30.46.54.14

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to