[R] plotting multiple animal tracks against Date/Time
Struve, Juliane
j.struve at imperial.ac.uk
Wed Sep 29 13:52:43 CEST 2010
I will post the example again to see if its readable now. My question is why
does read.zoo(file=filenames,....) work and lapply(filenames, read.zoo,...) does not ? Since I am reading the same file in both statements I just do not know how to interpret "Error in strptime(x, format, tz = tz) : invalid 'x' argument".
Thank you for all help.
Juliane
library(chron)
library(zoo)
#Generate example file
Fish_ID=1646
Date <- "01/01/2004 00:01:00"
Date <- as.POSIXct(strptime(Date,format="%m/%d/%Y %H:%M:%S"))
R2sqrt <-100
Test <- data.frame(Fish_ID=Fish_ID,Date=Date,R2sqrt=R2sqrt)
write.csv(Test,file="Test")
#Read in example file
filenames="Test"
read.zoo(file=filenames, header = TRUE, FUN = as.chron, sep = ",", colClasses = c("NULL", "NULL", "character", "numeric"))
lapply(filenames, read.zoo, header = TRUE, FUN = as.chron, sep = ",", colClasses = c("NULL", "NULL", "character", "numeric"))
________________________________________
From: Gabor Grothendieck [ggrothendieck at gmail.com]
Sent: 29 September 2010 00:09
To: Struve, Juliane
Cc: r-help at r-project.org
Subject: Re: [R] plotting multiple animal tracks against Date/Time
On Tue, Sep 28, 2010 at 9:30 AM, Struve, Juliane
<j.struve at imperial.ac.uk> wrote:
>
> 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.
Self contained means anyone else can just copy your code and paste it
into their session and see the error message you see.
Its likely that your file does not contain what you think it does.
--
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