[R-SIG-Finance] [r-sig-finance] Package Quantmod: reading csv files

Gabor Grothendieck ggrothendieck at gmail.com
Thu Jun 4 15:36:57 CEST 2009


Try this (noting that quantmod pulls in zoo and
xts as well):

> Lines <- "Date,Open,High,Low,Close,Volume
+ 2009-01-02 09:00:00,2476,2478,2468,2469,5140
+ 2009-01-02 09:01:00,2469,2469,2459,2464,2998
+ 2009-01-02 09:02:00,2464,2464,2459,2462,1985
+ 2009-01-02 09:03:00,2462,2468,2461,2468,1694
+ 2009-01-02 09:04:00,2468,2469,2466,2467,605
+ 2009-01-02 09:05:00,2467,2468,2466,2468,996
+ 2009-01-02 09:06:00,2468,2469,2467,2469,1241"
> library(quantmod)
> z <- read.zoo(textConnection(Lines), header = TRUE, sep = ",", tz = "")
> x <- as.xts(z)
> chartSeries(x)


On Thu, Jun 4, 2009 at 9:16 AM, anass <anass.mouhsine at gmail.com> wrote:
> Hi all,
>
> I started to work on the package quantmod, but I have trouble reading simple
> csv files.
> The first lines of the file are as follows.
>
> Date,Open,High,Low,Close,Volume
> 2009-01-02 09:00:00,2476,2478,2468,2469,5140
> 2009-01-02 09:01:00,2469,2469,2459,2464,2998
> 2009-01-02 09:02:00,2464,2464,2459,2462,1985
> 2009-01-02 09:03:00,2462,2468,2461,2468,1694
> 2009-01-02 09:04:00,2468,2469,2466,2467,605
> 2009-01-02 09:05:00,2467,2468,2466,2468,996
> 2009-01-02 09:06:00,2468,2469,2467,2469,1241
>
> I read few days ago a thread on the subject, but it seems to me that the
> kinf of file I try to read is easier since the time is given in the first
> column.
>
> What I tried to do is the following:
>
>> t<-getSymbols('STXE',src='csv')
> Error in dimnames(x) <- dn :
>  length of 'dimnames' [2] not equal to array extent
> In addition: Warning messages:
> 1: In structure(.Internal(as.POSIXct(x, tz)), class = c("POSIXt",
> "POSIXct"),  :
>  unknown timezone ' ET'
> 2: In structure(.Internal(as.POSIXct(x, tz)), class = c("POSIXt",
> "POSIXct"),  :
>  unknown timezone ' ET'
> 3: In structure(.Internal(as.POSIXct(x, tz)), class = c("POSIXt",
> "POSIXct"),  :
>  unknown timezone ' ET'
> 4: In structure(.Internal(as.POSIXct(x, tz)), class = c("POSIXt",
> "POSIXct"),  :
>  unknown timezone ' ET'
> 5: In structure(.Internal(as.POSIXct(x, tz)), class = c("POSIXt",
> "POSIXct"),  :
>  unknown timezone ' ET'
>
> any thoughts on the subject?
>
> Anass
> --
>
> En toda ocasion, disfruta de la vida
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>



More information about the R-SIG-Finance mailing list