[R] Creating xts objects from csv file
Joshua Ulrich
jo@h@m@u|r|ch @end|ng |rom gm@||@com
Tue Jul 21 16:28:03 CEST 2020
Your example works for me. Can you provide a sample of the CSV you're
trying to read, and the commands you use to read it? The output of
sessionInfo() might also be helpful.
On Mon, Jul 20, 2020 at 3:42 PM Jeff Reichman <reichmanj using sbcglobal.net> wrote:
>
> R-Help Forum
>
>
>
> Starting to work with xts objects but can't figure out what I'm doing wrong
> when converting *.csv file with a dtg variable to a *.xts object. When I'm
> converting to an appropriate time object all I get are NA, so that's my
> first issue.
>
>
>
> dtg <- c("1/5/2010 2:30", "1/5/2010 10:32", "1/5/2010 12:03")
>
> seq <- c(1,2,3)
>
>
>
> dat <- data.frame(dtg, seq)
>
>
>
> dat$dtg <- as.POSIXlt(dat$dtg, format = "%m/%d/%Y %H:%M")
>
>
>
> dat.xts <- xts(x = dat[,-1], order.by = dat[,1])
>
>
>
> head(dat.xts)
>
>
>
> Sincerely
>
>
>
> Jeff Reichman
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
--
Joshua Ulrich | about.me/joshuaulrich
FOSS Trading | www.fosstrading.com
More information about the R-help
mailing list