[R] The time series analysis functions/packages don't seem to like my data

Ted Byers r.ted.byers at gmail.com
Fri Jul 3 23:48:53 CEST 2009


I have hundreds of megabytes of price data time series, and perl
scripts that extract it to tab delimited files (I have C++ programs
that must analyse this data too, so I get Perl to extract it rather
than have multiple connections to the DB).

I can read the data into an R object without any problems.

thedata = read.csv("K:\\Work\\SignalTest\\BP.csv", sep = "\t", header
= FALSE, na.strings="")
thedata

The above statements give me precisely what I expect.  The last few
lines of output are:
8190 2009-06-16 49.30
8191 2009-06-17 48.40
8192 2009-06-18 47.72
8193 2009-06-19 48.83
8194 2009-06-22 46.85
8195 2009-06-23 47.11
8196 2009-06-24 46.97
8197 2009-06-25 47.43

I have loaded Rmetrics and PerformanceAnalytics, among other packages.
 I tried as.timeseries, but R2.9.1 tells me there is no such function.
I tried as.ts(thedata), but that only replaces the date field by the
row label in 'thedata'.

If I apply the performance analytics drawdowns function to either
thedata or thedate$V2, I get errors:
> table.Drawdowns(thedata,top = 10)
Error in 1 + na.omit(x) : non-numeric argument to binary operator
> table.Drawdowns(thedata$V2, top = 10)
Error in if (thisSign == priorSign) { :
  missing value where TRUE/FALSE needed
>

thedata$V2 by itself does give me the price data from the file.

I am a relative novice in using R for timeseries, so I wouldn't be
surprised it I missed something that would be obvious to someone more
practiced in using R, but I don't see what that could be from the
documentation of the functions I am looking at using.  I have no
shortage of data, and I don't want to write C++ code, or perl code, to
do all the kinds of calculations provided in, Rmetrics and
performanceanalytics, but getting my data into the functions these
packages provide is killing me!

What did I miss?

Thanks

Ted




More information about the R-help mailing list