Joshua, Jeff
I was debugging the getSymbols.FRED() function and realized that there is a
potential "problem" with the xts(). ("quoted" because it is more likely a
problem with the way timezones are handled by R within Windows)

If I download directly FRED data (as in the body of getSymbols.FRED() ) I
get the correct CSV file and the first column has all the correct dates
(i.e, no NA).

Then,

> as.Date(fr[, 1], origin = "1970-01-01")

returns all the dates also without NAs (note that fr is the result from fr
<- read.csv(...) )

But, when running

> fr <- xts(as.matrix(fr[, -1]), as.Date(fr[, 1], origin = "1970-01-01"),
src = "FRED", updated = Sys.time())
> sum(is.na(index(fr)))
[1] 2

!!

It is interesting that the NAs appear at 2004-11-02 and 1997-10-06. Both the
exchange rates at these dates correctly appear in the result, the only
problem is that the index has NA instead of the above mentioned dates. At
first, I though it was something related to holidays (since November 2nd is
a holiday) but that is not true for 1997-10-06.

See below some info from my R session:
-------
> sessionInfo()
R version 2.11.1 (2010-05-31)
i386-pc-mingw32

locale:
[1] LC_COLLATE=Portuguese_Brazil.1252  LC_CTYPE=Portuguese_Brazil.1252
[3] LC_MONETARY=Portuguese_Brazil.1252 LC_NUMERIC=C
[5] LC_TIME=Portuguese_Brazil.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] quantmod_0.3-13 TTR_0.20-2      Defaults_1.1-1  xts_0.7-5
[5] zoo_1.6-4

loaded via a namespace (and not attached):
[1] grid_2.11.1    lattice_0.18-8 tools_2.11.1

> Sys.getenv('TZ')
                 TZ
"America/Sao_Paulo"

> Sys.timezone()
[1] "BRT"
 --------

Any idea why the xts() function is adding NAs for those two specific dates ?
(by the way, the same problem happens regardless of which daily exchange
rate series I download from FRED, and the NAs appear always at those two
dates)

Thanks a lot.
-Paulo





On Sun, Sep 26, 2010 at 12:47 PM, Joshua Ulrich <josh.m.ulrich@gmail.com>wrote:

> On Sun, Sep 26, 2010 at 9:52 AM, Paulo Grahl <pgrahl@gmail.com> wrote:
> > Dear all,
> > I've downloaded the following exchange rate data from FRED
> >
> > library(quantmod)
> > getSymbols("DEXBZUS",src="FRED")
> >
> > And it happens that there are a couple of NA's, not in the data, but in
> the
> > index(DEXBZUS).
>
> Are you doing something after downloading and before checking the
> index for NA values?  I ask because there are no NA index values when
> I download the data.
>
> > getSymbols("DEXBZUS",src="FRED")
> [1] "DEXBZUS"
> > sum(is.na(index(DEXBZUS)))
> [1] 0
>
> > Using na.omit() does not exclude these data points from the time series.
> > I could obviously exclude this points by searching the index() of the
> > series, but I was wondering if xts already has some functionality that
> could
> > handle these cases.
>
> You can do this by using is.na() on the index:
>
> > (x <- xts(1:10,as.Date(c(1:9,NA))))
>           [,1]
> 1970-01-02    1
> 1970-01-03    2
> 1970-01-04    3
> 1970-01-05    4
> 1970-01-06    5
> 1970-01-07    6
> 1970-01-08    7
> 1970-01-09    8
> 1970-01-10    9
> <NA>         10
> > x[!is.na(index(x))]
>           [,1]
> 1970-01-02    1
> 1970-01-03    2
> 1970-01-04    3
> 1970-01-05    4
> 1970-01-06    5
> 1970-01-07    6
> 1970-01-08    7
> 1970-01-09    8
> 1970-01-10    9
>
> HTH,
> --
> Joshua Ulrich
> FOSS Trading: www.fosstrading.com
>
>
>
> > Thanks
> > Paulo
> >
> >
> > --
> > Paulo Gustavo Grahl, CFA
> > ------------------------------------------
> > pgrahl@gmail.com
> > pgrahl@fgvmail.br
> > +55(21) 8809-9254
> > skype:paulo.grahl
> > www.linkedin.com/in/pgrahl
> > ------------------------------------------
> >
> >        [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-SIG-Finance@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.
> > -- Also note that this is not the r-help list where general R questions
> should go.
> >
>



-- 
Paulo Gustavo Grahl, CFA
------------------------------------------
pgrahl@gmail.com
pgrahl@fgvmail.br
+55(21) 8809-9254
skype:paulo.grahl
www.linkedin.com/in/pgrahl
------------------------------------------

	[[alternative HTML version deleted]]

