[AniMov] Cannot create ltraj object

Morellet Nicolas Nicolas.Morellet at toulouse.inra.fr
Tue Jul 8 11:06:54 CEST 2014


Hello Elodie,

Could you try ?
data_used = droplevels(data_used)
Maybe some individuals are present in the id variable (if this is a 
factor variable) but with missing component(s).

Cheers,
Nicolas.


Le 08/07/2014 10:21, Elodie Camprasse a écrit :
>
> Folks,
>
> I have been encountering a problem when using the adehabitatLT package 
> and specifically the function as.ltraj and I was hoping someone could 
> give me a clue on how to solve the problem!
>
> I am working with GPS data. I have got 20 different files with tracks that I have merged together; it looks like I have successfully created a POSIXct column that I added to the dataframe and I have one column with latitude and one with longitude, as well as an ID column that has the ID of my individual birds; however, when I use the as.ltraj function, I get the following error: "Error in as.ltraj(xy = data_used[, c("latitude", "longitude")], date = data_used$timestamp,  :
>
>   some id's are not present in the data"
>
> I tried different things (without naming the columns first and with 
> column names, with or without "-" in the ID numbers, using just the 
> relevant columns with no additional information...) and nothing is 
> fixing the problem. I also do not understand the error message because 
> when I check the length of the relevant columns, there are the same.
>
> Here is my code:
>
> setwd("C:/Users/Elodie/Documents/Deakin/Data analysis/GPS data 
> analysis/Processed LB multiple tracks")
>
> file_list<-list.files(pattern="*.csv", full.names=TRUE)
>
> require(data.table)
>
> #merge all the files in the working directory in one dataframe
>
> dataset = rbindlist(lapply( file_list, fread ))
>
> write.csv(dataset, file = "dataset_multiple_trips_LB.csv", row.names = F)
>
> data<-read.csv("dataset_multiple_trips_LB.csv", header=F)
>
> data_used<-data[-1,]
>
> #V3 is the Date column, V4 is the Time column
>
> timestamp <- as.POSIXct(strptime(as.character(paste(data_used$V3, 
> data_used$V4)),"%Y/%m/%d %H:%M:%S"), "GMT")
>
> data_used <- data.frame(data_used, V11 = timestamp)
>
> colnames(data_used)<-c("id", "index", "date", "time", "latitude", 
> "longitude", "speed", "course", "distance", "EHPE", "timestamp")
>
> everybody<-as.ltraj(xy = data_used[,c("latitude","longitude")], date = 
> data_used$timestamp, id = data_used$id)
>
> Error in as.ltraj(xy = data_used[, c("latitude", "longitude")], date = data_used$timestamp,  :
>    some id's are not present in the data
>
> If I do the following code, I get the following results
>
> >length(data_used$id)
> [1] 14444
> >length(data_used$timestamp)
> [1] 14444
> >length(data_used$longitude)
> [1] 14444
> >length(data_used$latitude)
> [1] 14444.
>
> Thanks in advance for pointing me in the right direction!
> Elodie
>
> Elodie Camprasse
>
> 6/187 Auburn Road
>
> Hawthorn, VIC 3122
>
> Australia
>
> Email: elodie.camprasse at gmail.com <mailto:elodie.camprasse at gmail.com>
>
> Website: http://hors-des-sentiers-battus.e-monsite.com/
>
> Mobile: (+61) 049 794 0793 <tel:%28%2B61%29%20049%20794%200793>
>
>
>
> _______________________________________________
> AniMov mailing list
> AniMov at faunalia.it
> http://lists.faunalia.it/cgi-bin/mailman/listinfo/animov


-- 


**********************************************************
                    Nicolas MORELLET
I.N.R.A. - Centre de Recherches de Toulouse
Comportement et Écologie de la Faune Sauvage (C.E.F.S.)
BP 52627 - 31326 Castanet-Tolosan cedex (France)
               Tel :  05.61.28.51.28
               Fax :  05.61.28.55.00
**********************************************************



---
Ce courrier électronique ne contient aucun virus ou logiciel malveillant parce que la protection avast! Antivirus est active.
http://www.avast.com
-------------- section suivante --------------
Une pi?ce jointe HTML a ?t? nettoy?e...
URL: <http://lists.faunalia.it/pipermail/animov/attachments/20140708/23f6544d/attachment-0001.html>


More information about the AniMov mailing list