Monday, January 26, 2009

Mashing up dropbox and R

This has to be one of my favourite things I've ever done with dropbox. I'm running a survey test in R on a whole bunch of data for a time series assignment (just running the test on everything like this is definitely the lazy way to do this, and I was always taught lazy is good in math). Since I was worried about the computer crashing while the test ran I'm outputting the test results to files. At the last moment I thought that it would be great to have this automatically backed up and accessible remotely. So I'm saving the output files to dropbox, with the result summary in the file name. In other words I am doing this:
>for(p in (2:3)){for(D1 in (0:1)){for(q in (2:15)){for(P in (0:1)){for(Q in (0:1)){
+ testmodel<-arima(x=tsphone, order=c(p,0,q), seasonal=list(order=c(P,D1+1,Q))); + print(p); print(q); print(P); print(D1+1); print(Q); print(testmodel); + save(testmodel, file=paste("./Dropbox/question2/", testmodel$aic,p,q,P,D1+1, Q, ".rdata")); + }}}}}

And since the smallest aic is probably the right model I can just sort the directory and see the best results at the top. I'm very happy about this.

No comments: