Hi guys
I have a reasonably basic question with zoo usage, but I havent been able
to find a satisfactory workaround yet.
Heres a simple example of what I'm talking about (the following data frame
contains numeric columns that contains NAs):
> head(ebs)
time src tstamp code bid ask
1 2009-03-03 13:03:29.536 perf.Tib_listener 14980321164
EBS.REC.EURJPY=EBS.NaE 123.48 NA
2 2009-03-03 13:03:29.786 perf.FilteringPublisher 14980565658 EUR.JPY.SPOT
123.48 123.51
3 2009-03-03 13:03:29.786 perf.Tib_listener 14980566116
EBS.REC.EURJPY=EBS.NaE NA 123.51
4 2009-03-03 13:03:30.036 perf.FilteringPublisher 14980824852 EUR.JPY.SPOT
123.49 123.50
5 2009-03-03 13:03:30.051 perf.Tib_listener 14980835694
EBS.REC.EURJPY=EBS.NaE 123.49 123.50
6 2009-03-03 13:03:30.520 perf.FilteringPublisher 14981302082 EUR.JPY.SPOT
123.49 123.51
> class(ebs)
[1] "data.frame"
> class(ebs$bid)
[1] "numeric"
> any(is.na(ebs$bid))
[1] TRUE
> class(ebs$ask)
[1] "numeric"
> foo <- zoo(ebs)
> class(coredata(foo$bid))
[1] "character"
So it looks like zoo() might be doing some type coercion. I want to
interpolate the NAs using na.locf() and then perform some calculations, but
am a bit puzzled as to why zoo is turning the numeric columns into
characters.
Does anyone know if I am doing something wrong here? Is it because the
column contains NAs?
Cheers
Rory
[[alternative HTML version deleted]]
______________________________________________
[email protected] 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.