[R-sig-eco] include Time in as.ltraj()

Glen Sargeant gsargeant at usgs.gov
Fri Jun 12 00:41:20 CEST 2009



Struve, Juliane wrote:
> 
> Dear list,
> 
> I am trying to create an ltraj object from but can't get the date - time
> information right.
> 
> All_1646=read.table("All_1646.csv", sep=",",header=TRUE,as.is=TRUE )
> All_1646$Date=as.Date(All_1646$Date)
> attr(All_1646, "projection") <- c("LL")
> All_1646<- convUL(All_1646,km=FALSE)
> All_1646$Datime <-as.POSIXct(paste(All_1646$Date, All_1646$Time),
> "%Y/%m/%d %H:%M:%S")
> ltr1646 <- as.ltraj(All_1646, date=All_1646$Datime, id=All_1646$"Fish_ID",
> typeII = TRUE)
> 
> I get an error message "Error in as.ltraj(All_1646, date =
> All_1646$Datime, id = All_1646$Fish_ID,  :
> non unique dates for a given burst".
> 
> However, the Datime column does include the time of observation as shown
> below. What am I doing wrong ?
> 
> 
> 
> Many thanks for your time,
> 
> 
> 
> Juliane
> 
> 
> 
> Datime
> 2006-08-18 08:48:59
> 
> 	[[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
> 
> 


Juliane,

In general, you can learn about any error message by inspecting code that
generated it.  To view the code for any function, submit the function name
(no trailing parentheses) from the command prompt.  

In this specific case:

>as.ltraj

If you inspect the code for as.ltraj, you will find the following
expressions:

    rr <- any(unlist(lapply(res, function(x) (length(unique(x$date)) != 
        length(x$date)))))
    if (rr) 
        stop("non unique dates for a given burst")

'as.ltraj' compares the length of 'date' to the length of a vector
containing only unique values in date and returns an error message when they
are unequal (i.e., when 'date' contains duplicates).

Glen Sargeant


-- 
View this message in context: http://n2.nabble.com/include-Time-in-as.ltraj%28%29-tp3063163p3064895.html
Sent from the r-sig-ecology mailing list archive at Nabble.com.



More information about the R-sig-ecology mailing list