[AniMov] Re: ...other problems

Clément Calenge calenge at biomserv.univ-lyon1.fr
Mon Feb 14 11:32:56 CET 2005


Hello,

>fagiani$date <- as.POSIXct ( strptime (fagiani$date, format = "%y%m%d"))
> > fagiani
>     id     x     y       date
>1  739 39100 42560 2005-12-04
>2  799 39100 42570 2005-12-04
>3  908 39100 42570 2005-12-04
>4  847 36210 40150 2005-12-04
>5  925 36240 40200 2005-12-04
>6  986 36060 40230 2005-12-04
>7  847 36230 40110 2005-12-04
>8  986 36050 40240 2005-02-14
>9  925 36310 40320 2005-12-04
>10 708 36950 40240 2005-12-04
>11 749 36950 40240 2005-12-21
>
> > tr <- as.traj(id = id, xy = xy, date = fagiani$date)
>Error in if ((as.numeric(x$date))[i] == (as.numeric(x$date))[i - 1]) 
>ind[i] <-
>1 :
>         missing value where TRUE/FALSE needed

This means that the date has not been converted to the class POSIXct. 
Indeed, in your case,
the format argument of the function strptime is not "%y%m%d" (which means 
"year without century",
"month" and "day", without separator, e.g. 051204). If your data have the 
form 2005-12-04, you should
use the format "%Y-%m-%d" (which means "year with century", "month", and 
"day", separated by a -).
In other words, use:

fagiani$date <- as.POSIXct ( strptime (fagiani$date, format = "%Y-%m-%d"))

The format argument depends on your data. See the help page of strptime for 
further info.
Hope this helps,


Clément.

======================================
Clément CALENGE
LBBE - UMR CNRS 5558 - Université Claude Bernard Lyon 1 - FRANCE
tel. (+33) 04.72.43.27.57
fax. (+33) 04.72.43.13.88




More information about the AniMov mailing list