Ted Byers
2009-Jul-03 21:48 UTC
[R] The time series analysis functions/packages don't seem to like my data
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
Mark Knecht
2009-Jul-03 22:39 UTC
[R] The time series analysis functions/packages don't seem to like my data
On Fri, Jul 3, 2009 at 2:48 PM, Ted Byers<r.ted.byers at gmail.com> wrote:> 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 > > ______________________________________________ > 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. >Could you supply some portion of the results when you run the example on your data? The example goes like: data(edhec) R=edhec[,"Funds.of.Funds"] findDrawdowns(R) sortDrawdowns(findDrawdowns(R)) How are you using the function with your data? - Mark
Reasonably Related Threads
- R problem: unable to read data in the xls-format in the PerformAnalytics package
- Adding a vertical line to plot with two overlapping density plots
- Problem with mpi.close.Rslaves()
- Rmpi task-pull
- how to create analog stripchart plots of x vs t (t=mm/dd/yyyy hh:mm:ss)