The simplest way to do this is to use colClasses to specify that you want
POSIXct: see the documentation for read.table.
strptime returns an object of class POSIXlt (a list of length 9), and you
cannot put that in a data frame. So the issue is not that stated in the
subject line: apply strptim
it's probably a factor, not a string vector...
so i would do as.vector or as.character - but it may be not necessary !
as.POSIXct(strptime(as.vector(A$date),...))
or:
seq( from = ISOdate(2006,02,28, 12, 0, 0, tz=""),
to = ISOdate(...), by="30 min")
Andrew Athan a écrit :
>
> A$date is al
Try prepending as.POSIXct
A[,1] <- as.POSIXct(strptime(A$date,"%Y-%m-%d %H:%M:%s"))
A.
On Mon, Mar 06, 2006 at 11:58:01PM -0500, Andrew Athan wrote:
>
> I'm sure this is just the result of a basic misunderstanding of the
> syntax of R, but I am stumped.
>
> A <-
> read.table(file="sumByThirt
POSIXct, not POSIXlt, are used in data frame columns.
See ?POSIXct where this is mentioned and try:
A$date <- as.POSIXct(A$date)
Also be sure to read R News 4/1 for more about dates and times.
On 3/6/06, Andrew Athan <[EMAIL PROTECTED]> wrote:
>
> I'm sure this is just the result of a basic mis
A$date is already a string, as read from the file. I tried it anyway,
for you...
> A$date<-strptime(as.character(A$date),"%Y-%m-%d %H:%M:%s")
Error in "$<-.data.frame"(`*tmp*`, "date", value = list(sec = c(0, 0, :
replacement has 9 rows, data has 3198
>
A.
Jacques VESLOT wrote:
> m
maybe you need to transform A$date to character:
A$date <- strptime(as.character(A$date), ...)
see also:
?ISOdatetime
Andrew Athan a écrit :
>I'm sure this is just the result of a basic misunderstanding of the
>syntax of R, but I am stumped.
>
>A <-
>read.table(file="sumByThirtyMinute.csv",sep
I'm sure this is just the result of a basic misunderstanding of the
syntax of R, but I am stumped.
A <-
read.table(file="sumByThirtyMinute.csv",sep=",",col.names=c("date","pandl"))
A now consists of thousands of rows, but A$date is a string...
...
3183 2006-02-28 12:00:00548.470
3184 2006-