Hi all!
I've found the solution - the ordering of the series is important. It's
expected that the most recent entries are located at the bottom of the
data matrix. Here's the sorting command:
x <- sort(x, decreasing = FALSE)
Kind regards:
Gero
Gero Schwenk schrieb:> Hi there!
> I'm stuck with a problem aligning financial timeseries and haven't
> found a cue how to fix it...
>
> When I run that simple script, everything goes well until the
> "align"-command:
>
> ------
> rm(list=ls())
> x <- yahooSeries("^GDAXI")
> head(x)
> xAligned <- align(x = x, by = "1d", method =
"before",
> include.weekends = FALSE)
> ------
>
> Here's the command-line dialog:
>
> ------
> > rm(list=ls())
> > x <- yahooSeries("^GDAXI")
> versuche URL
>
'http://chart.yahoo.com/table.csv?s=^GDAXI&a=&b=&c=&d=8&e=07&f=2009&g=d&x=.csv'
>
> Content type 'text/csv' length unknown
> URL ge?ffnet
> .......... .......... .......... .......... ..........
> .......... .......... .......... .......... ..........
> .......... .......... .......... .......... ..........
> .......... .......... .......... .......... ..........
> .......... .......... .......... .......... ..........
> ......
> downloaded 256 Kb
>
> > head(x)
> GMT
> ^GDAXI.Open ^GDAXI.High ^GDAXI.Low ^GDAXI.Close ^GDAXI.Volume
> 2009-09-04 5328.59 5404.30 5320.28 5384.43 28535100
> 2009-09-03 5332.50 5364.03 5278.50 5301.42 25969000
> 2009-09-02 5325.94 5337.84 5263.11 5319.84 30401300
> 2009-09-01 5479.35 5507.48 5327.29 5327.29 31245400
> 2009-08-31 5474.62 5495.56 5437.92 5458.04 10442600
> 2009-08-28 5512.17 5573.89 5502.46 5517.35 23480600
> ^GDAXI.Adj.Close
> 2009-09-04 5384.43
> 2009-09-03 5301.42
> 2009-09-02 5319.84
> 2009-09-01 5327.29
> 2009-08-31 5458.04
> 2009-08-28 5517.35
> > xAligned <- align(x = x, by = "1d", method =
"before",
> include.weekends = FALSE)
> Fehler in seq.default(u[1] + offset, u[length(u)], by = by) :
> wrong sign in 'by' argument
> -----
>
> Besides, Example-Data (SWX) from the "fPortfolio"-package is
aligned
> nicely by exactly the same command. Does anybody have an idea what the
> problem could be? I'm grateful for any help!
>
> Kind regards,
> Gero
>
> ______________________________________________
> 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.
>