Hello! Im really not a whiz at this stuff so please bear with me.... 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. Thanks! Mike -- View this message in context: http://www.nabble.com/as.ltraj-error%3A-date-should-be-of-the-same-length-as-xy-tp25156508p25156508.html Sent from the R help mailing list archive at Nabble.com.
Clément Calenge
2009-Aug-27 07:06 UTC
[R] as.ltraj error: date should be of the same length as xy
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