[R] plotting multiple animal tracks against Date/Time

Struve, Juliane j.struve at imperial.ac.uk
Tue Sep 28 15:30:42 CEST 2010


Hi,

in this self-contained example the file the same error message appears as when I read in my original results files.

library (zoo)
library(chron)
#generate example data
Fish_ID=1646
 Date <- "01/01/2004 00:01:00"
 Date <- as.POSIXct(strptime(Date,format="%m/%d/%Y %H:%M:%S"))
 R2sqrt <-100
#put into dataframe
Test <- data.frame(Fish_ID=Fish_ID,Date=Date,R2sqrt=R2sqrt)
# write .csv file
write.csv(Test,file="Test")
#generate list of files
filenames="Test"
#read file(s) into zoo object
read.zoo(file=filenames, header = TRUE, FUN = as.chron, sep = ",", colClasses = c("NULL", "NULL", "character", "numeric")) #works fine
#read list of files into zoo.object
lapply(filenames, read.zoo, header = TRUE, FUN = as.chron, sep = ",", colClasses = c("NULL", "NULL", "character", "numeric"))# error
"Error in strptime(x, format, tz = tz) : invalid 'x' argument"

Am I missing something ?

Thank you for your time and patience.


Juliane

Sorry for posting twice, libraries were missing earlier.
________________________________________
From: Gabor Grothendieck [ggrothendieck at gmail.com]
Sent: 27 September 2010 23:32
To: Struve, Juliane
Cc: r-help at r-project.org
Subject: Re: [R] plotting multiple animal tracks against Date/Time

On Mon, Sep 27, 2010 at 5:38 PM, Struve, Juliane
<j.struve at imperial.ac.uk> wrote:
> Hello,
>
> thank you very much for replying. The code yields an error message
>
> Error in strptime(x, format, tz = tz) : invalid 'x' argument
>
> But I can't see what's wrong with it, the Date/Time info  is in the third column, format is
> "%Y-%m-%d %H:%M:%S". There is no time zone info in the data, could this be a problem ?
>

See the last line on every message to r-help.  You need to put
together a minimal self contained example that illustrates the
problem.
The best I can do with the information provided is to point out that this works:

> Lines <- '"","Fish_ID","Date","R2sqrt"
+ "1",1646,2006-08-18 08:48:59,0
+ "2",1646,2006-08-18 09:53:20,100'
>
> library(zoo)
> library(chron)
> read.zoo(textConnection(Lines), header = TRUE, FUN = as.chron,
+  sep = ",", colClasses = c("NULL", "NULL", "character", "numeric"))
(08/18/06 08:48:59) (08/18/06 09:53:20)
                  0                 100






--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com


More information about the R-help mailing list