[tech-spec] help with function

  • From: tim hesselsweet <tim_hess1@xxxxxxxxx>
  • To: tech-spec@xxxxxxxxxxxxx
  • Date: Mon, 28 Mar 2005 17:17:54 -0800 (PST)

i've got a time series object in splus w/finmetrics
containing monthly observations.  i'm trying to use
the function aggregateSeries to transform the monthly
obs. into non-overlapping quarterly and semi-annual
obs. but i need a function for the FUN argument.  any
ideas to correct/replace the function pickClose below?
 if all else fails, i'll just use Fm.df[c(....)] and
try to make a counter to avoid cutting and pasting the
series. 

> pickClose <- function(x) {
+ if(length(dim(x)))x=as.vector(as.matrix(x))
+ len <- length(x)
+ if(!len)
+    as(NA,class(x))
+ else x[len]
+ }

//quarterly
> qtr <-
aggregateSeries(Fm.ts,FUN=pickClose,by="quarters")
//semi-annually
>  semi <-
aggregateSeries(Fm.ts,FUN=pickClose,by="quarters",k.by=2)

thanks, 

tim


                
__________________________________ 
Do you Yahoo!? 
Read only the mail you want - Yahoo! Mail SpamGuard. 
http://promotions.yahoo.com/new_mail 

Other related posts:

  • » [tech-spec] help with function