[R] as.xts
arun
smartpink111 at yahoo.com
Wed Oct 17 22:12:28 CEST 2012
Hi,
Sorry, I didn't looked at the title. If you need to get the xts object
Try this:
dat1<-read.table(text="
reportDate total
1 2010-12-31 170609.2
2 2011-01-03 170778.0
3 2011-01-04 170748.4
4 2011-01-05 170599.5
5 2011-01-06 170335.0
6 2011-01-07 169842.1
",sep="",header=TRUE,stringsAsFactors=FALSE)
library(xts)
dat2<-xts(dat1$total,order.by=as.POSIXct(dat1$reportDate,format="%Y-%m-%d"))
str(dat2)
#An ‘xts’ object from 2010-12-31 to 2011-01-07 containing:
# Data: num [1:6, 1] 170609 170778 170748 170600 170335 ...
#Indexed by objects of class: [POSIXct,POSIXt] TZ:
#xts Attributes:
#List of 2
# $ tclass: chr [1:2] "POSIXct" "POSIXt"
# $ tzone : chr ""
dat2
[,1]
#2010-12-31 170609.2
#2011-01-03 170778.0
#2011-01-04 170748.4
#2011-01-05 170599.5
#2011-01-06 170335.0
#2011-01-07 169842.1
A.K.
----- Original Message -----
From: sf631 <chad.gray at gmail.com>
To: r-help at r-project.org
Cc:
Sent: Wednesday, October 17, 2012 3:15 PM
Subject: Re: [R] as.xts
I'm not the original poster, but I do have the same question.
I have pulled in data via RODBC into a data frame, which looks like below
and I'm getting the same error message:
/("Error in as.POSIXlt.character(x, tz, ...) :
character string is not in a standard unambiguous format")
/
The date format seems pretty straightforward to me so I'm kind of stuck at
what to do. BTW, I'm *very* new to R so please forgive some ignorance here
reportDate total
1 2010-12-31 170609.2
2 2011-01-03 170778.0
3 2011-01-04 170748.4
4 2011-01-05 170599.5
5 2011-01-06 170335.0
6 2011-01-07 169842.1
--
View this message in context: http://r.789695.n4.nabble.com/as-xts-tp3028280p4646499.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list