its/0000755000175100001440000000000011251001252011054 5ustar hornikusersits/INDEX0000644000175100001440000000272211250465002011657 0ustar hornikusersExtract Extract or Replace Parts of an Object its Irregularly Spaced Time-Series itsAccessor Accessor, Assignment Functions for Irregular Time-Series Objects itsArith Arithmetic Methods for Irregular Time-Series Objects itsConvert Conversion for its objects itsCumdif Cumulation, Differencing for Irregular Time-Series Objects itsDisp Display Methods for Irregular Time-Series Objects itsFile File Operations for Irregular Time-Series Objects itsFin Financial Functions for Irregular Time-Series Objects itsInfo Summary Information for Irregular Time-Series Objects itsInterp Interpolation Functions for Irregular Time-Series Objects itsJoin Join Functions for Irregular Time-Series Objects itsLags Lag Functions for Irregular Time-Series Objects itsSubset Range and Extract for Irregular Time-Series Objects itsTimes Time Functions for Irregular Time-Series Objects [<--methods ~~ Methods for Function [<- in Package 'its' ~~ priceIts Download Historical Finance Data its/inst/0000755000175100001440000000000011251001061012027 5ustar hornikusersits/inst/examples/0000755000175100001440000000000011250465002013655 5ustar hornikusersits/inst/examples/examples.r0000644000175100001440000000074411250465002015663 0ustar hornikusers#a cautionary tale newIts(start="2003-10-28",end="2004-10-05",by="month") #OK newIts(start="2003-10-30",end="2004-10-05",by="month") #unexpected newIts(start="2003-10-31",end="2004-10-05",by="month") #unexpected newIts(start="2003-09-31",end="2004-10-05",by="month") #unexpected newIts(start="2003-09-31",end="2005-05-05",by="day",period="month",find="last",extract=TRUE) #unexpected newIts(start="2003-09-31",end="2005-05-05",by="DSTday",period="month",find="last",extract=TRUE) #OK its/inst/changes0000644000175100001440000000623111251001057013371 0ustar hornikusersits package release notes 1.1.8 2009-09-06 1 patch from Maxim Krikun to fix union w/ 0 column argument 2 testsuite cleanup 3 format cleanup for some functions 1.1.5 2006-09-09 1 added its,numeric and numeric,its S4 methods for Arith 1.1.3 2006-09-09 1 changed old dates in test.r 1.1.2 2006-09-09 1 removed install.R 2 removed README from top level 1.1.1 2005-10-23 1 fixed itsAccessor example (sometimes produced less than 10 date elements due to DST changes in some European timezones. 1.1.0 2005-10-01 1 dropped resriction on using tzone attribute for dates 1.0.8 2005-05-26 1 made as.its generic 2 added compression argument to priceIts contributed by John Bollinger 1.0.7 2005-05-22 1 added as.list.its and as.data.frame.its to exported names 1.0.6 2005-05-16 1 added ... to the args of generic dates() 2 fixed bug in locf() dates 3 removal of tzone attribute from dates slot 4 some changes to extractIts, including a bugfix (affected yearends in some cases) 1.0.4 2004-12-01 1 its now forces all tzones to be UTM, unless tzone is already an attribute of the dates used to create the its object 2 the Arith group now takes the intersection of the dates. The past behavior was to fail unless the dates matched exactly. 1.0.3 2004-04-16 1 fixed bug in priceIts() using patch from Dirk Eddelbuettel 1.0.2 2004-04-16 1 fixed bug in newIts() 1.0.1 2004-03 1 added require(stats) namespace directive for 1.9.0 1.0.0 2004-02-12 [n.b. for version>=1.9.0 will need additional namespace directive import(stats)] 0 licence changed to GPL Version 2 1 new function 'locf()' (last observation carry forward) 2 writecsvIts gets extra option 'split' to split large files 3 as(its,"data.frame") implemented 4 POSIXlt arguments are coerced to POSIXct 5 NA handled properly in summary() 6 new function priceIts() 0.2.1 2004-01-06 1 bugfix version to pass Rcmd check on R-devel (0.2.0 not released on CRAN) some fixes to method documentation removed direct calls to POSIX methods for format, plot, seq replaced export() with exportClasses() in namespace 0.2.0 2003-12-16 1 new functions: newIts, extractIts, collapseIts 2 new 'lab' option in plot for labelling series 3 'leg' option in plot now uses labcurve(), not locator() 4 renamed the function classifications in documentation (itsFunctions, not its-functions) 5 dates() accessor & assignment methods for dates 6 names() accessor & assignment functions for the dimnames(matrix)[[2]] 7 core() accessor & assignment functions for the matrix 8 revised summary() 9 the package is now in a namespace - a number of internal functions have therefore been withdrawn 10 added a 'dates' option for row selection using POSIXct in extractor: [i,j,dates] 11 optional use of POSIXct dates in rangeIts 12 CRAN package Hmisc is now required 0.1.2 2003-09-20 1 removed logic to take special action on logical subscripts 2 allow append() to operate on NULL 3 fix and extend documentation 4 'at' passed to axis.POSIXct() by plot() 5 'format' passed to axis.POSIXct() by plot() 6 handling of NAs in plot() - options 7 linetype options in plot() 0.1.1 2003-07-22 its/inst/test/0000755000175100001440000000000011250714712013023 5ustar hornikusersits/inst/test/releaseProcedure.txt0000644000175100001440000000074511250465002017056 0ustar hornikusersRelease procedure Testing and development h:/dev/its Final checks : Rcmd check its Rcmd build --force its Rcmd build --binary its Rcmd INSTALL --save its Run the test procedure /inst/test.r Install from binary & run test procedure svn commit and tag Protect .tar.gz FTP upload of .tar.gz at the command prompt: ftp cran.r-project.org anonymous your.email.address@yourserver.com cd ./incoming put ./its_i.j.k.tar.gz quit Email to cran@r-project.org; Kurt.Hornik@wu-wien.ac.at its/inst/test/test.r0000644000175100001440000006040111250714712014166 0ustar hornikusersrequire(its) addDimnames <- function(mat) { if(is.null(dimnames(mat))) {dimnames(mat) <- list(NULL,NULL)} if(is.null(dimnames(mat)[[1]])&(nrow(mat)>0)) {dimnames(mat)[[1]] <- 1:nrow(mat)} if(is.null(dimnames(mat)[[2]])&(ncol(mat)>0)) {dimnames(mat)[[2]] <- 1:ncol(mat)} return(mat) } test <- function(x) { if(!x) stop() } today <- as.POSIXct(format(Sys.time(),"%Y-%m-%d")) mytimes <- seq.POSIXt(from=today,by="DSTday",length.out=10) attr(mytimes,"tzone") <- "" mat <- addDimnames(matrix(1:30,10,3)) dimnames(mat)[[2]] <- c("A","B","C") its.format("%Y-%m-%d") x <- its(mat,mytimes) moretimes <- seq.POSIXt(from=today+1,by="DSTday",length.out=11) more <- addDimnames(matrix(1:33,11,3)) dimnames(more)[[2]] <- c("A","B","C") x2 <- its(more,moretimes) ##its-arith********************************************************** ##arith-methods------------------------------------------------------ test.arith <- function() { y1 <- x[,1]+x[,2] y2 <- its(x@.Data[,1,drop=FALSE]+x@.Data[,2,drop=FALSE],mytimes) test(all.equal(y1@.Data,y2@.Data)) test(all.equal(y1@dates,y2@dates)) y1 <- x[,1]+x[,2]*pi y2 <- its(x@.Data[,1,drop=FALSE]+x@.Data[,2,drop=FALSE]*pi,mytimes) test(all.equal(y1@.Data,y2@.Data)) test(all.equal(y1@dates,y2@dates)) y1 <- x[,1]+pi y2 <- its(x@.Data[,1,drop=FALSE]+pi,mytimes) test(all.equal(y1@.Data,y2@.Data)) test(all.equal(y1@dates,y2@dates)) } ##extractor********************************************************** test.extractor <- function() { y1 <- x[,1,dates=dates(x)[1:5]] y2 <- x[1:5,1] y3 <- y1+y2 test(all(dates(y1)==dates(x)[1:5])) test(all(core(y1)==core(x)[1:5,1])) } ##names************************************************************** test.names <- function() { test(all(names(x)==dimnames(core(x))[[2]])) y1 <- x names(y1) <- letters[1:ncol(y1)] test(all(names(y1)==letters[1:ncol(y1)])) } ##dates************************************************************** test.dates <- function() { test(all(dates(x)==x@dates)) y1 <- x dates(y1) <- moretimes[1:nrow(y1)] test(all(dates(y1)==moretimes[1:nrow(y1)])) } ##core*************************************************************** test.core <- function() { test(all(core(x)==x@.Data)) y1 <- x core(x) <- addDimnames(matrix(101:130,10,3)) test(all(core(x)==addDimnames(matrix(101:130,10,3)))) } ##its-cumdif********************************************************* ##cumsum-method------------------------------------------------------ test.cumsum <- function() { foo <- cumsum(x) test(all.equal(foo@.Data[,1],cumsum(x@.Data[,1]))) test(all.equal(foo@dates,mytimes)) } ##diff-method-------------------------------------------------------- test.diff <- function() { foo <- diff(cumsum(x)) bar <- alignedIts(foo,x,print=FALSE) test(all.equal(bar[[1]],bar[[2]])) } ##its-def************************************************************ ##-Functions- ##is.its-function---------------------------------------------------- test.is.its <- function() { test(is.its(x)) test(!is.its(x@.Data)) test(!is.its(x@dates)) } ##as.its-function---------------------------------------------------- test.as.its <- function() { foo <- as.numeric(mat[,1,drop=F]) class(foo) <- c("POSIXt","POSIXct") bar <- its(mat[,-1],foo) waz <- as.its(mat) test(all.equal(bar,waz)) } ##its-function------------------------------------------------------- test.its.creation <- function() { test(all.equal(x@dates,mytimes)) test(all.equal(x@.Data/mat,x@.Data/x@.Data)) ##parameters ## years <- 100:105 ## hoursecs <- 60*60 ## regdaysecs <- 24*hoursecs ## monthdays <- c(28,29,30,31) ## monthsecs <- c(monthdays*regdaysecs,monthdays*regdaysecs-hoursecs,monthdays*regdaysecs+hoursecs) ## weeksecs <- 7*regdaysecs ##+hoursecs*c(-1,0,1) ## daysecs <- regdaysecs+hoursecs*c(-1,0,1) ## its.format("%Y-%m-%d") } ##***newIts ##newIts-from test.new.its <- function() { its.format("%Y-%m-%d") mystarts <- c("2003-01-01","2002-12-31","2003-11-17","2004-10-27") myends <- c("2003-02-01","2003-12-31","2004-12-17","2004-11-01") for(ddd in mystarts) { TEST <- newIts(start=ddd) test(start(TEST)==ddd) } ##newIts-to for(ddd in myends) { TEST <- newIts(start="2002-11-17",end=ddd) test(end(TEST)==ddd) } for(i in 1:3) { TEST <- newIts(start=mystarts[i],end=myends[i]) test((start(TEST)==mystarts[i])&(end(TEST)==myends[i])) } ##newIts-by now <- as.POSIXct(format(Sys.time(),"%Y-%m-%d")) its.end.date <- now+100*24*60*60 day.range <- seq.POSIXt(from=now,to=its.end.date,by="DSTday") TEST <- newIts(end=format(its.end.date,"%Y-%m-%d")) test(all.equal(day.range,TEST@dates)) month.range <- seq.POSIXt(from=as.POSIXct("2003-10-01"),to=as.POSIXct("2010-12-01"),by="months") TEST <- newIts(start="2003-10-01",end="2010-12-01",by="month") test(all.equal(month.range,TEST@dates)) week.range <- seq.POSIXt(from=now,to=its.end.date,by="weeks") TEST <- newIts(end=format(its.end.date,"%Y-%m-%d"),by="week") test(all.equal(week.range,TEST@dates)) ##newIts-ncol ncol(newIts(end=format(its.end.date,"%Y-%m-%d"),ncol=5))==5 ##***extractIts permutations ##-weekday weekDaySelection <- c(0,6) nowt <- newIts(extract=TRUE,weekday=TRUE,select=weekDaySelection) test(length(nowt)==0) weekDaySelection <- 1:5 TEST1 <- newIts(extract=TRUE,weekday=TRUE) TEST2 <- newIts(extract=TRUE,weekday=TRUE,select=weekDaySelection) TEST3 <- newIts() test(length(TEST1)>0) test(length(TEST2)==length(TEST1)) test(length(TEST3)>length(TEST2)) test(all(as.POSIXlt(TEST1@dates)$wday%in%weekDaySelection)) test(all(weekDaySelection%in%as.POSIXlt(TEST1@dates)$wday)) ##-find ("all","last","first") test(identical(newIts(extract=TRUE,select=0:6,period="week"),newIts())) test(identical(newIts(extract=TRUE,select=0:6,period="week",find="all"),newIts())) TEST1 <- newIts(extract=TRUE,period="week",find="first",partial=FALSE) TEST2 <- newIts(extract=TRUE,select=0,period="week") test(all(TEST1%in%TEST2)) TEST1 <- newIts(extract=TRUE,period="week",find="last",partial=FALSE) TEST2 <- newIts(extract=TRUE,select=6,period="week") test(all(TEST1%in%TEST2)) TEST1 <- newIts(weekday=TRUE,extract=TRUE,period="week",find="first",partial=FALSE) TEST2 <- newIts(weekday=TRUE,extract=TRUE,select=1,period="week") test(all(TEST1%in%TEST2)) TEST1 <- newIts(weekday=TRUE,extract=TRUE,period="week",find="last",partial=FALSE) TEST2 <- newIts(weekday=TRUE,extract=TRUE,select=5,period="week") test(all(TEST1%in%TEST2)) ##-period test(all(as.POSIXlt(newIts(extract=TRUE,period="week",find="first",partial=FALSE)@dates)$wday==0)) test(all(as.POSIXlt(newIts(extract=TRUE,period="week",find="last",partial=FALSE)@dates)$wday==6)) test(all(as.POSIXlt(newIts(extract=TRUE,period="month",find="first",partial=FALSE)@dates)$mday==1)) test(all(as.POSIXlt(newIts(extract=TRUE,period="month",find="last",partial=FALSE)@dates)$mday%in%28:31)) test(identical(newIts(extract=TRUE,period="week",select=0:6),newIts())) test(identical(newIts(extract=TRUE,period="month",select=1:31),newIts())) ##-partials TEST <- newIts(start="2003-11-18") TEST1 <- newIts(start="2003-11-18",period="week",find="first",extract=TRUE,partial=TRUE) TEST2 <- newIts(start="2003-11-18",period="week",find="first",extract=TRUE,partial=FALSE) TEST@dates[1]==TEST1@dates[1] test((nrow(TEST1)-1)==nrow(TEST2)) ##-select for(i in 0:6) { TEST <- newIts(extract=TRUE,period="week",select=i) test(all(as.POSIXlt(TEST@dates)$wday==i)) } for(i in 30:31) { TEST <- newIts(extract=TRUE,period="month",select=i) test(all(as.POSIXlt(TEST@dates)$mday==i)) } } ##its-disp*********************************************************** ##plot-method-------------------------------------------------------- ##create 5 sinusoids differing in phase by pi/6 test.plot.its <- function() { its.format("%Y-%m-%d %X") sintimes <- seq.POSIXt(from=Sys.time(),by=24*60*60,length.out=100) sintimes.num <- as.numeric(sintimes) sinmat <- addDimnames(matrix(NA,100,5)) for(j in 1:5){sinmat[,j] <- sin((6*pi*sintimes.num/(sintimes.num[100]-sintimes.num[1]))-j*pi/6)} dimnames(sinmat)[[2]] <- LETTERS[1:5] sinx <- its(sinmat,sintimes) par(mfrow=c(3,3)) ##line,point plot(sinx,type="p",main="Point") plot(sinx,type="l",main="Line") plot(sinx,type="b",main="Both") ##colour, width, type cycling plot(sinx,lwdvec=1:3,main="Width") plot(sinx,ltypvec=1:3,main="Type") plot(sinx,colvec=c(1,2,7),main="Colour") ##axis plot(sinx,format="%B",main="Label") plot(sinx,at=sintimes[c(1,100)],main="Position") ##NA handling sinx[10:20,] <- sinx[10:20,]*NA sinx[,2] <- sinx[,2]*NA plot(sinx,interp="n",main="NAs") } ##print-method------------------------------------------------------- print(x) ##its-file*********************************************************** ##writecsvIts-function----------------------------------------------- test.read.write.its <- function() { file <- tempfile() writecsvIts(x,file,col.names=FALSE) writecsvIts(x,file,row.names=FALSE,col.names=FALSE) writecsvIts(x,file) ##readcsvIts-function------------------------------------------------ foo <- its(readcsvIts(file)) y <- its(x) test(identical(as.numeric(foo@.Data),as.numeric(y@.Data))) test(all.equal(foo@dates,y@dates)) test(identical(dimnames(foo),dimnames(y))) } ##its-fin************************************************************ ##accrueIts-function------------------------------------------------- ##test(all.equal(accrueIts(x)-lagIts(x)[-1,]/(365),accrueIts(x)*0)) ##its-info*********************************************************** ##summary-method----------------------------------------------------- test.its.summary <- function() { foo <- summary(x) test(all.equal(as.numeric(foo[1,]),seq(1,21,10))) test(all.equal(as.numeric(foo[6,]),seq(10,30,10))) test(all.equal(as.numeric(foo[8,]),rep(10,3))) } ##start-method------------------------------------------------------- test.its.start <- function() { test(identical(start(x,format="%Y-%m-%d-%X"),format.POSIXct(mytimes[1],format="%Y-%m-%d-%X"))) test(identical(start(x[2:nrow(x),],format="%Y-%m-%d-%X"),format.POSIXct(mytimes[2],format="%Y-%m-%d-%X"))) } ##end -method-------------------------------------------------------- test.its.end <- function() { test(identical(end(x,format="%Y-%m-%d %X"),format.POSIXct(mytimes[10],format="%Y-%m-%d %X"))) test(identical(end(x[1:(nrow(x)-1),],format="%Y-%m-%d %X"),format.POSIXct(mytimes[nrow(x)-1],format="%Y-%m-%d %X"))) } ##its-join*********************************************************** ##alignedIts-function--------------------------------------------- test.aligned.its <- function() { its.format("%Y-%m-%d") isub <- seq(1,9,2) xsub <- x[isub,] foo <- alignedIts(x,xsub,print=F) ##identical is not working here test(identical(foo[[1]],xsub)) test(identical(foo[[2]],xsub)) test(identical(foo[[1]]@dates,xsub@dates)) test(identical(core(foo[[1]]),core(xsub))) } ##appendIts-function------------------------------------------------- test.append.its <- function() { its.format("%Y-%m-%d %X") xx <- its(mat,mytimes) ## these operations change the order of the attributes of the date ## after this, identical can't be used to compare series ## because the attributes order does not match later <- mytimes+366*24*60*60 over <- mytimes+5*24*60*60 xlate <- its(mat,later) xover <- its(mat,over) foo <- appendIts(xx,xlate) bar <- appendIts(xlate,xx) test(all.equal(foo,bar)) test(all.equal(foo[1:10],xx)) ## test(identical(foo[11:20],xlate)) test(all.equal(foo[11:20],xlate)) foo <- try(appendIts(x,xx[(2:(nrow(x)-1)),],but=FALSE),silent=TRUE) test(identical(grep("appendor data must extend appendee data",foo)>0,TRUE)) foo <- try(appendIts(x,xover,but=FALSE),silent=TRUE) test(identical(grep("overlap data does not match",foo)>0,TRUE)) foo <- try(appendIts(x,xover),silent=TRUE) test(foo=="Error in appendIts(x, xover) : overlap not allowed\n") dimnames(xlate)[[2]][1] <- "Z" foo <- try(appendIts(x,xlate),silent=TRUE) test(foo=="Error in appendIts(x, xlate) : names of the two inputs must match\n") ##10 cases ## S1 E1 S2 E2 ## 1 1 2 3 4 ## 2 1 3 2 4 ## 3 1 4 2 3 ## 4 2 3 1 4 ## 5 2 4 1 3 ## 6 3 4 1 2 ## 7 1 2 2 2 ## 8 1 2 3 3 ## 9 2 3 1 1 ##10 1 2 1 1 ## 1 1 2 3 4 x1 <- xx[1:4,] x2 <- xx[5:8,] foo <- appendIts(x1,x2,but=FALSE,matchnames=FALSE) test(identical(xx[1:8,],foo)) foo <- appendIts(x1,x2,but=FALSE,matchnames=TRUE) test(identical(xx[1:8,],foo)) foo <- appendIts(x1,x2,but=TRUE,matchnames=FALSE) test(identical(xx[1:8,],foo)) foo <- appendIts(x1,x2,but=TRUE,matchnames=TRUE) test(identical(xx[1:8,],foo)) ## 2 1 3 2 4 x1 <- xx[1:4,] x2 <- xx[3:6,] foo <- appendIts(x1,x2,but=FALSE,matchnames=FALSE) test(identical(xx[1:6,],foo)) foo <- appendIts(x1,x2,but=FALSE,matchnames=TRUE) test(identical(xx[1:6,],foo)) foo <- try(appendIts(x1,x2,but=TRUE,matchnames=FALSE),silent=TRUE) test(identical(grep("overlap not allowed",foo)>0,TRUE)) foo <- try(appendIts(x1,x2,but=TRUE,matchnames=TRUE),silent=TRUE) test(identical(grep("overlap not allowed",foo)>0,TRUE)) ## 3 1 4 2 3 x1 <- xx[1:4,] x2 <- xx[2:3,] foo <- try(appendIts(x1,x2,but=FALSE,matchnames=FALSE),silent=TRUE) test(identical(grep("appendor data must extend appendee data",foo)>0,TRUE)) foo <- try(appendIts(x1,x2,but=FALSE,matchnames=TRUE),silent=TRUE) test(identical(grep("appendor data must extend appendee data",foo)>0,TRUE)) foo <- try(appendIts(x1,x2,but=TRUE,matchnames=FALSE),silent=TRUE) test(identical(grep("overlap not allowed",foo)>0,TRUE)) foo <- try(appendIts(x1,x2,but=TRUE,matchnames=TRUE),silent=TRUE) test(identical(grep("overlap not allowed",foo)>0,TRUE)) ## 4 2 3 1 4 x1 <- xx[2:3,] x2 <- xx[1:4,] foo <- try(appendIts(x1,x2,but=FALSE,matchnames=FALSE),silent=TRUE) test(identical(grep("appendor data must extend appendee data",foo)>0,TRUE)) foo <- try(appendIts(x1,x2,but=FALSE,matchnames=TRUE),silent=TRUE) test(identical(grep("appendor data must extend appendee data",foo)>0,TRUE)) foo <- try(appendIts(x1,x2,but=TRUE,matchnames=FALSE),silent=TRUE) test(identical(grep("overlap not allowed",foo)>0,TRUE)) foo <- try(appendIts(x1,x2,but=TRUE,matchnames=TRUE),silent=TRUE) test(identical(grep("overlap not allowed",foo)>0,TRUE)) ## 5 2 4 1 3 x1 <- xx[2:4,] x2 <- xx[1:3,] foo <- appendIts(x1,x2,but=FALSE,matchnames=FALSE) test(identical(xx[1:4,],foo)) foo <- appendIts(x1,x2,but=FALSE,matchnames=TRUE) test(identical(xx[1:4,],foo)) foo <- try(appendIts(x1,x2,but=TRUE,matchnames=FALSE),silent=TRUE) test(identical(grep("overlap not allowed",foo)>0,TRUE)) foo <- try(appendIts(x1,x2,but=TRUE,matchnames=TRUE),silent=TRUE) test(identical(grep("overlap not allowed",foo)>0,TRUE)) ## 6 3 4 1 2 x1 <- xx[3:4,] x2 <- xx[1:2,] foo <- appendIts(x1,x2,but=FALSE,matchnames=FALSE) test(identical(xx[1:4,],foo)) foo <- appendIts(x1,x2,but=FALSE,matchnames=TRUE) test(identical(xx[1:4,],foo)) foo <- appendIts(x1,x2,but=TRUE,matchnames=FALSE) test(identical(xx[1:4,],foo)) foo <- appendIts(x1,x2,but=TRUE,matchnames=TRUE) test(identical(xx[1:4,],foo)) ## 7 1 2 2 2 x1 <- xx[1:4,] x2 <- xx[4,] foo <- appendIts(x1,x2,but=FALSE,matchnames=FALSE) test(identical(xx[1:4,],foo)) foo <- appendIts(x1,x2,but=FALSE,matchnames=TRUE) test(identical(xx[1:4,],foo)) foo <- try(appendIts(x1,x2,but=TRUE,matchnames=FALSE),silent=TRUE) test(identical(grep("overlap not allowed",foo)>0,TRUE)) foo <- try(appendIts(x1,x2,but=TRUE,matchnames=TRUE),silent=TRUE) test(identical(grep("overlap not allowed",foo)>0,TRUE)) ## 8 1 2 3 3 x1 <- xx[1:4,] x2 <- xx[5,] foo <- appendIts(x1,x2,but=FALSE,matchnames=FALSE) test(identical(xx[1:5,],foo)) foo <- appendIts(x1,x2,but=FALSE,matchnames=TRUE) test(identical(xx[1:5,],foo)) foo <- appendIts(x1,x2,but=TRUE,matchnames=FALSE) test(identical(xx[1:5,],foo)) foo <- appendIts(x1,x2,but=TRUE,matchnames=TRUE) test(identical(xx[1:5,],foo)) ## 9 2 3 1 1 x1 <- xx[2:4,] x2 <- xx[1,] foo <- appendIts(x1,x2,but=FALSE,matchnames=FALSE) test(identical(xx[1:4,],foo)) foo <- appendIts(x1,x2,but=FALSE,matchnames=TRUE) test(identical(xx[1:4,],foo)) foo <- appendIts(x1,x2,but=TRUE,matchnames=FALSE) test(identical(xx[1:4,],foo)) foo <- appendIts(x1,x2,but=TRUE,matchnames=TRUE) test(identical(xx[1:4,],foo)) ##10 1 2 1 1 x1 <- xx[2:4,] x2 <- xx[2,] foo <- appendIts(x1,x2,but=FALSE,matchnames=FALSE) test(identical(xx[2:4,],foo)) foo <- appendIts(x1,x2,but=FALSE,matchnames=TRUE) test(identical(xx[2:4,],foo)) foo <- try(appendIts(x1,x2,but=TRUE,matchnames=FALSE),silent=TRUE) test(identical(grep("overlap not allowed",foo)>0,TRUE)) foo <- try(appendIts(x1,x2,but=TRUE,matchnames=TRUE),silent=TRUE) test(identical(grep("overlap not allowed",foo)>0,TRUE)) } ##union-method------------------------------------------------------- test.union.its <- function() { its.format("%Y-%m-%d") isub <- seq(1,9,2) ioth <- setdiff(1:10,isub) xsub <- x[isub,] xun <- union(x,xsub) test(identical(xun[,1:3],x)) test(identical(xun[isub,4:6],xsub)) test(all(is.na(xun[ioth,4:6]))) } ##intersect-method--------------------------------------------------- test.intersect.its <- function() { its.format("%Y-%m-%d") isub <- seq(1,9,2) xsub <- x[isub,] xin <- intersect(x,xsub) test(identical(xin[,1:3],xsub)) test(identical(xin[,4:6],xsub)) } ##its-lags*********************************************************** ##lagIts-function---------------------------------------------------- test.lag.its <- function() { foo <- lagIts(x) test(all(foo[-1,]==x[-nrow(x),])) test(all(foo@dates==x@dates)) } ##lagdistIts-function------------------------------------------------ test.lagdist.its <- function() { foo <- lagdistIts(x[,1],1,3) test(all.equal(foo[,1],lagIts(x[,1],1))) test(all.equal(foo[,2],lagIts(x[,1],2))) test(all.equal(foo[,3],lagIts(x[,1],3))) test(all.equal(x@dates,foo@dates)) } ##its-subset********************************************************* ##rangeIts-function-------------------------------------------------- test.its.range <- function() { its.format("%Y-%m-%d") now <- format.POSIXct(Sys.time(),format=its.format()) tomorrow <- format.POSIXct(Sys.time()+24*60*60,format=its.format()) test(identical(appendIts(rangeIts(x,start=tomorrow),rangeIts(x,end=now)),x)) test(nrow(rangeIts(x,start=now,end=now))==1) test(nrow(rangeIts(x,start=now,end=tomorrow))==2) } test.subset.its <- function() { ##[-method----------------------------------------------------------- i1 <- rep(c(TRUE,FALSE),5) j1 <- c(TRUE,FALSE,TRUE) test(all(x[2:8,2:3]==mat[2:8,2:3])) test(all(x[3,3]==mat[3,3])) test(all(x[0,0]==mat[0,0])) test(all(x[-2,]==mat[-2,])) test(all(x[,-2]==mat[,-2])) test(all(x[,j1]==mat[,j1])) test(all(x[,j1]==mat[,j1])) test(all(x[i1,j1]==mat[i1,j1])) test(all(mat[c(TRUE,FALSE,TRUE),]==x[c(TRUE,FALSE,TRUE),])) test(all(mat[,c(TRUE,FALSE)]==x[,c(TRUE,FALSE)])) mat2 <- mat x2 <- x mat2[c(TRUE,FALSE),c(TRUE,FALSE)] <- c(1000,2000) x2[c(TRUE,FALSE),c(TRUE,FALSE)] <- c(1000,2000) test(all(mat2==x2)) } ##its-times********************************************************** ##daysecondIts-function---------------------------------------------- ##weekdayIts-function------------------------------------------------ test.times.its <- function() { foo <- as.POSIXlt(mytimes)$wday test(identical((foo>0 & foo<6),weekdayIts(x))) } ##collapseIts-------------------------------------------------------- test.collapse.its <- function() { foo <- newIts(ncol=4,period="week",find="last",extract=T)[1:5,] foo[,1] <- c(NA,NA,NA,1,1) foo[,2] <- 1 foo[,4] <- c(NA, 1, 1,1,1) dimnames(foo)[[2]] <- c("A","A","B","A") test(all.equal(collapseIts(foo),foo[,2:3])) foo[5,1] <- 1.01 bar <- try(collapseIts(foo),silent=TRUE) test(bar=="Error in collapseIts(foo) : column data must match in collapse function\n") } ##its-utilities****************************************************** ###################################################################################################################################################################################### ##fromirtsIts-function------------------------------------------------ ##identical(fromirtsIts(irts(x@dates,x)),x) ##locf--------------------------------------------------------------- test.locf.its <- function() { foo <- x foo[2:4,] <- NA test(identical(dates(x),dates(foo))) } ##-Utility Methods- ##validity check----------------------------------------------------- ##dates<--method----------------------------------------------------- ##[-method----------------------------------------------------------- ##-Utility Functions- ##addDimnames-function----------------------------------------------- ##gap.its-function--------------------------------------------------- ##overlaps.its-function---------------------------------------------- ##overlapmatches.its-function---------------------------------------- ##namesmatch.its-function-------------------------------------------- ##its.format-function------------------------------------------------ ##simdates.its-function---------------------------------------------- ##***extractDates test.extract.its <- function() { its.format("%Y-%m-%d") years <- 100:105 hoursecs <- 60*60 regdaysecs <- 24*hoursecs monthdays <- c(28,29,30,31) monthsecs <- c(monthdays*regdaysecs,monthdays*regdaysecs-hoursecs,monthdays*regdaysecs+hoursecs) weeksecs <- 7*regdaysecs ##+hoursecs*c(-1,0,1) daysecs <- regdaysecs+hoursecs*c(-1,0,1) weekDaySelection <- 1:5 TEST <- newIts(start="2003-11-17",end="2005-12-25") ##-select test(all((as.numeric(extractIts(TEST,period="week",select=2)@dates)-as.numeric(extractIts(TEST,period="week",select=1)@dates)) %in% daysecs)) ##-weekday test(all(as.POSIXlt(extractIts(TEST,weekday=TRUE)@dates)$wday %in%1:5)) test(all(as.POSIXlt(extractIts(TEST,weekday=TRUE,find="last")@dates)$wday %in%1:5)) test(all(as.POSIXlt(extractIts(TEST,weekday=TRUE,select=weekDaySelection)@dates)$wday %in%weekDaySelection)) test(all(as.POSIXlt(extractIts(TEST,weekday=TRUE,select=weekDaySelection,period="week",find="last")@dates)$wday==5)) test(all(as.POSIXlt(extractIts(TEST,weekday=TRUE,select=weekDaySelection,period="week",find="first")@dates)$wday==1)) ##-find test(all(as.POSIXlt(extractIts(TEST,weekday=TRUE,period="week",find="first")@dates[-1])$wday==1)) TESTX <-extractIts(TEST[1:(length(TEST@dates)-2)],weekday=TRUE,period="week",find="last")@dates test(all(as.POSIXlt(TESTX)$wday[-length(TESTX)]==5)) ##-period test(all(as.POSIXlt(extractIts(TEST,weekday=FALSE,period="year",find="first",partial=FALSE)@dates)$yday==0)) test(all(as.POSIXlt(extractIts(TEST,weekday=FALSE,period="month",find="last",partial=FALSE)@dates)$mday%in%monthdays)) test(all(as.POSIXlt(extractIts(TEST,weekday=FALSE,period="month",find="first",partial=FALSE)@dates)$mday==1)) test(all(as.POSIXlt(extractIts(TEST,weekday=FALSE,period="week",find="first",partial=FALSE)@dates)$wday==0)) test(all(as.POSIXlt(dates(extractIts(newIts(start="2001-12-21",end="2002-01-10")[-10:-11,],find="last",period="week",partial=FALSE)))$wday ==6)) ##firstlast test(start(extractIts(TEST,per="y",find="f",firstlast=TRUE))==start(TEST)&&end(extractIts(TEST,,per="y",find="f",firstlast=TRUE))==end(TEST)) ##-select test(all((as.numeric(extractIts(TEST,period="week",select=2)@dates)-as.numeric(extractIts(TEST,period="week",select=1)@dates))%in%daysecs)) test(all(as.POSIXlt(extractIts(TEST,period="week",select=2)@dates)$wday==2)) test(all(as.POSIXlt(extractIts(TEST,period="week",select=2,weekday=TRUE)@dates)$wday==2)) } testIts <- function() { test.arith() test.extractor() test.names() test.dates() test.core() test.cumsum() test.diff() test.is.its() test.as.its() test.its.creation() test.new.its() ##test.plot.its() test.read.write.its() test.its.summary() test.its.start() test.its.end() test.aligned.its() test.append.its() test.union.its() test.intersect.its() test.lag.its() test.lagdist.its() test.its.range() test.subset.its() test.times.its() test.collapse.its() test.locf.its() test.extract.its() } cat(paste("* its test suite successful *\n",R.version.string,"\n")) ##debug(testIts) print(system.time(testIts())) its/inst/dev/0000755000175100001440000000000011250465002012615 5ustar hornikusersits/inst/dev/lagIts.R0000644000175100001440000000064311250465002014166 0ustar hornikusers#lagIts-function---------------------------------------------------- lagIts <- function(x,k=1) { if (!inherits(x, "its")) stop("function is only valid for objects of class 'its'") lagmat <- x*NA dimnames(lagmat)[[2]] <- paste(dimnames(lagmat)[[2]],"lag",k) n <- dim(x)[1] if(k>0) {lagmat[(k+1):n,] <- x[1:(n-k),]} else {lagmat[1:(n+k),] <- x[(1-k):n,]} return(lagmat) } its/DESCRIPTION0000644000175100001440000000070611251011410012562 0ustar hornikusersPackage: its Version: 1.1.8 Date: 2009-09-06 Title: Irregular Time Series Author: Portfolio & Risk Advisory Group, Commerzbank Securities Maintainer: Whit Armstrong Depends: R (>= 2.0.0), methods, stats, Hmisc Description: The its package contains an S4 class for handling irregular time series LazyLoad: yes License: GPL-2 Packaged: 2009-09-06 18:42:50 UTC; whit Repository: CRAN Date/Publication: 2009-09-06 19:52:40 its/R/0000755000175100001440000000000011250715110011261 5ustar hornikusersits/R/itsmisc.R0000644000175100001440000000055011250524430013062 0ustar hornikusers as.list.its <- function(x,...) { result <- if (ncol(x) == 1) list(x) else lapply(seq(length = ncol(x)), function(i) x[,i]) names(result) <- colnames(x) result } as.data.frame.its <- function(x, row.names = NULL, optional = FALSE, ...) { result <- lapply(as.list(x), I) result$check.names <- result$check.rows <- optional do.call(data.frame, result) } its/R/itspkg.R0000644000175100001440000007544711250711551012733 0ustar hornikusers## itspkg.r: a time series package in R ## Copyright (C) 2003 to 2004 Commerzbank Securities ## Copyright (C) 2004 to present Whit Armstrong itsState <- new.env() assign(x=".itsformat", value="%Y-%m-%d" , env=itsState) setClass("its",representation("matrix",dates="POSIXt")) ##-Methods- ##names-method------------------------------------------------------- namesIts <- function(x) { return(dimnames(x@.Data)[[2]]) } setMethod("names",signature(x="its"),namesIts) ##"names<-"-method--------------------------------------------------- "names<-Its" <- function(x,value) { result <- x dimnames(result)[[2]] <- value return(result) } setMethod("names<-",signature(x="its",value="character"),get("names<-Its")) ##dates-method------------------------------------------------------- if(!isGeneric("dates")) {setGeneric("dates", function(x,...) standardGeneric("dates"))} datesIts <- function(x) { return(x@dates) } setMethod("dates",signature(x="its"),datesIts) ##"dates<-"-method--------------------------------------------------- if(!isGeneric("dates<-")) {setGeneric("dates<-", function(x,value) standardGeneric("dates<-"))} "dates<-Its" <- function(x,value) { if(!is(value,"POSIXt")) stop("dates should be in POSIX format") value <- as.POSIXct(value) result <- its(x@.Data,value) return(result) } setMethod("dates<-",signature(x="its",value="POSIXt"),get("dates<-Its")) ##core-method------------------------------------------------------- if(!isGeneric("core")) {setGeneric("core", function(x) standardGeneric("core"))} coreIts <- function(x) { return(x@.Data) } setMethod("core",signature(x="its"),coreIts) ##"core<-"-method--------------------------------------------------- if(!isGeneric("core<-")) {setGeneric("core<-", function(x,value) standardGeneric("core<-"))} "core<-Its" <- function(x,value) { result <- its(value,dates(x)) names(result) <- names(x) return(result) } setMethod("core<-",signature(x="its",value="matrix"),get("core<-Its")) ##arith-methods------------------------------------------------------ its.its.opp <- function(e1,e2) { ## take intersection of dates i.dates <- sort(intersect(dates(e1),dates(e2))) class(i.dates) <- c("POSIXt","POSIXct") ## add the data, taking the subset of the core for which the dates match ans <- callGeneric(e1[dates=i.dates,]@.Data,e2[dates=i.dates,]@.Data) ## make a new its w/ the ans and the dates intersection return(its(ans,i.dates)) } setMethod("Arith",signature(e1="its",e2="its"),its.its.opp) its.numeric.opp <- function(e1,e2) { ans <- callGeneric(e1@.Data,e2) return(its(ans,dates(e1))) } setMethod("Arith",signature("its", "numeric"),its.numeric.opp) numeric.its.opp <- function(e1,e2) { ans <- callGeneric(e1,e2@.Data) return(its(ans,dates(e2))) } setMethod("Arith",signature("numeric","its"),numeric.its.opp) ##plot-method-------------------------------------------------------- if(!isGeneric("plot")) setGeneric("plot", useAsDefault=plot) plotIts <- function(x,y,colvec=1:ncol(x),type="l",ltypvec=1,lwdvec=1, leg=FALSE,yrange,format,at,interp=c("linear","none"),lab=FALSE,...) { if(missing(yrange)){ylim <- range(x,na.rm=TRUE)} else {ylim <- yrange} interp <- match.arg(interp) firstp <- TRUE xdates <- x@dates n <- dim(x)[1] m <- dim(x)[2] ##make line control parameters correct length colveclong <- rep(colvec,length.out=m) ltypveclong <- rep(ltypvec,length.out=m) lwdveclong <- rep(lwdvec,length.out=m) for(i in 1:m) { if(interp=="linear") { vpoints <- c(1,which(!is.na(x[,i])),n) xxx <- x[,i] } else { vpoints <- 1:n xxx <- expandIts(x[,i]) } for (j in 1:ncol(xxx)) { if(!firstp){par(new=TRUE)}else {firstp <- FALSE} plot(x=xdates[vpoints], y=xxx[vpoints,j], type=type, col=colveclong[i], ylim=ylim, lty=ltypveclong[i], lwd=lwdveclong[i], xaxt="n", ...) } } if(lab) { labcurve(curves=gencurves(x), labels=dimnames(x)[[2]], col=colveclong, cex=.8) } else if(leg) { labcurve(curves=gencurves(x), labels=dimnames(x)[[2]], col=colveclong, lty=ltypveclong[i], lwd=lwdveclong[i], keys=rep(" ",ncol(x)), ##letters[1:ncol(x)], cex=.8) } grid() axis.POSIXct(x=xdates[vpoints],side=1,at=at,format=format) } setMethod("plot",signature(x="its",y="missing"),plotIts) ##print-method------------------------------------------------------- printIts <- function(x,...){ print(x@.Data,...) } setMethod("print",signature(x="its"),printIts) ##start-method------------------------------------------------------- startIts <- function(x,format=its.format(),...) { return(format(x@dates[1],format=format,...)) } setMethod("start",signature(x="its"),startIts) ##end-method-------------------------------------------------------- endIts <- function(x,format=its.format(),...) { return(format(x@dates[length(x@dates)],format=format,...)) } setMethod("end",signature(x="its"),endIts) ##summary-method----------------------------------------------------- summaryIts <- function(object,...) { r1 <- apply(object,2,min,na.rm=TRUE) r2a <- apply(object,2,quantile,probs=.25,na.rm=TRUE) r2b <- apply(object,2,quantile,probs=.5,na.rm=TRUE) r3 <- apply(object,2,mean,na.rm=TRUE) r4 <- apply(object,2,quantile,probs=.75,na.rm=TRUE) r5 <- apply(object,2,max,na.rm=TRUE) r6 <- apply(is.na(object),2,sum,na.rm=TRUE) r7 <- rep(nrow(object),ncol(object))-r6 r8 <- sqrt(apply(object,2,var,na.rm=TRUE)) mysum <- rbind(r1,r2a,r2b,r3,r4,r5,r6,r7,r8) dimnames(mysum)[[1]] <- c("Min.","1st Qu.","Median","Mean","3rd Qu.","Max.","NA's","non-NA's","s.d.") dimnames(mysum)[[2]] <- names(object) mysum } setMethod("summary",signature(object="its"),summaryIts) ##cumsum-method------------------------------------------------------ cumsumIts <- function(x) { y <- x for(j in 1:ncol(x)) {y[,j] <- cumsum(as.numeric(x[,j]))} return(y) } setMethod("cumsum",signature(x="its"),cumsumIts) ##diff-method-------------------------------------------------------- diffIts <- function(x,lag=1) { i <- NULL if((lag+1)<=length(x@dates)) i <- (lag+1):length(x@dates) y <- its(diff(x@.Data,lag=lag,drop=FALSE),dates=x@dates[i]) return(y) } setMethod("diff",signature(x="its"),diffIts) ##union-method------------------------------------------------------- unionIts <- function(x,y) { if(!is.null(x)&!is.null(y)) { dates1 <- x@dates dates2 <- y@dates alldates <- sort(union(dates1,dates2)) allnames <- c(dimnames(x)[[2]],dimnames(y)[[2]]) class(alldates) <- class(x@dates) m1 <- ncol(x) m2 <- ncol(y) n <- length(alldates) m <- m1+m2 united <- matrix(NA,nrow=n,ncol=m) if(m1>0) united[match(dates1,alldates),1:m1] <- x if(m2>0) united[match(dates2,alldates),(m1+1):m] <- y result <- its(united,dates=alldates,names=allnames) } if(is.null(x)) {result <- y} if(is.null(y)) {result <- x} return(result) } setMethod("union",signature(x="its",y="its"),unionIts) setMethod("union",signature(x="its",y="NULL"),unionIts) setMethod("union",signature(x="NULL",y="its"),unionIts) ##intersect-method--------------------------------------------------- intersectIts <- function(x,y) { if( !is.null(x) & !is.null(y) ) { dates1 <- x@dates dates2 <- y@dates alldates <- sort(intersect(dates1,dates2)) class(alldates) <- class(x@dates) allnames <- c(dimnames(x)[[2]],dimnames(y)[[2]]) m1 <- dim(x)[2] m2 <- dim(y)[2] n <- length(alldates) m <- m1+m2 united <- matrix(NA,n,m) drows1 <- sort(match(dates1,alldates)) drows2 <- sort(match(dates2,alldates)) srows1 <- sort(match(alldates,dates1)) srows2 <- sort(match(alldates,dates2)) united[drows1,1:m1] <- x[srows1,,drop=FALSE] united[drows2,(m1+1):m] <- y[srows2,,drop=FALSE] result <- its(united,dates=alldates,names=allnames) } if(is.null(x)) {result <- y} if(is.null(y)) {result <- x} return(result) } setMethod("intersect",signature(x="its",y="its"),intersectIts) setMethod("intersect",signature(x="its",y="NULL"),intersectIts) setMethod("intersect",signature(x="NULL",y="its"),intersectIts) ##as-method-------------------------------------------------------- as.data.frameIts <- function(from) { data.frame(core(from)) } setAs(from="its",to="data.frame",as.data.frameIts) ##-Functions- ##readcsvIts-function------------------------------------------------ readcsvIts <- function(filename,informat=its.format(),outformat=its.format(),tz="",usetz=FALSE,header=TRUE,...) { mydata <- read.csv(filename,header=header,...) n <- dim(mydata)[1] m <- dim(mydata)[2] datamat <- as.numeric(as.matrix((mydata)[,2:m,drop=FALSE])) dim(datamat) <- c(n,(m-1)) dimnames(datamat) <- list(dimnames(mydata)[[1]],dimnames(mydata)[[2]][2:m]) dimnames(datamat)[[1]] <- format(strptime(as.character(as.vector(mydata[,1])),informat), format=outformat,tz=tz,usetz=usetz) return(datamat) } ##writecsvIts-function----------------------------------------------- writecsvIts <- function(x,filename,format=its.format(),tz="",usetz=FALSE,col.names=NA,sep=",",split=FALSE,...) { if (!inherits(x, "its")) stop("function is only valid for objects of class 'its'") dimnames(x)[[1]] <- format(x@dates,format=format,tz=tz,usetz=usetz) y <- data.frame(x@.Data) dimnames(y) <- dimnames(x) if(split & ncol(x)>255) { jstart <- 1 jend <- 255 j <- 0 while(jstart0) { lagmat[(k+1):n,] <- x[1:(n-k),] } else { lagmat[1:(n+k),] <- x[(1-k):n,] } y <- its(lagmat,dates=x@dates) return(y) } ##lagdistIts-function------------------------------------------------ lagdistIts <- function(x,kmin,kmax) { if (!inherits(x, "its")) stop("function is only valid for objects of class 'its'") result <- lagIts(x,kmin) if(kmax>kmin) { for(j in (kmin+1):kmax) { result <- intersectIts(result,lagIts(x,j)) } } return(result) } ##alignedIts-function--------------------------------------------- alignedIts <- function(obj1,obj2,print=FALSE) { if( !inherits(obj1, "its") & inherits(obj2, "its") ) stop("function is only valid for objects of class 'its'") ##takes the intersection of the dates and extracts same dates for both mat <- intersectIts(obj1,obj2) obj1a <- mat[,1:ncol(obj1),drop=FALSE] obj2a <- mat[,(ncol(obj1)+1):ncol(mat),drop=FALSE] if(print) { print(paste("inputs number of rows",nrow(obj1),nrow(obj2),"; output number of rows",nrow(mat))) print(paste("inputs number of cols",ncol(obj1),ncol(obj2),"; output number of cols",ncol(obj1a),ncol(obj2a))) } list(obj1a,obj2a) } ##appendIts-function------------------------------------------------- appendIts <- function(obj1,obj2,but=TRUE,matchnames=TRUE) { if(is.null(obj1)&inherits(obj2, "its")) return(obj2) if(is.null(obj2)&inherits(obj1, "its")) return(obj1) if (!inherits(obj1, "its")&inherits(obj2, "its")) stop("function is only valid for objects of class 'its'") overlap <- overlapsIts(obj1,obj2) if(overlap & but) stop("overlap not allowed") nmatch <- namesmatchIts(obj1,obj2) if(matchnames && !nmatch) stop("names of the two inputs must match") if(overlap &&!overlapmatchesIts(obj1[,attr(nmatch,which="lut")],obj2)) stop("overlap data does not match") if(max(as.numeric(obj1@dates))<=max(as.numeric(obj2@dates))) { xlow <- obj1; xhigh <- obj2 } else { xlow <- obj2; xhigh <- obj1 } if(overlapsIts(obj1,obj2)) { highoverlap <- which(as.numeric(xhigh@dates)<=max(as.numeric(xlow@dates)) & as.numeric(xhigh@dates)>=min(as.numeric(xlow@dates))) xhigh <- xhigh[-highoverlap,] } if(matchnames) { united <- rbind(xlow[,attr(nmatch,which="lut")],xhigh) } else { united <- rbind(xlow,xhigh) } alldates <- c(xlow@dates,xhigh@dates) result <- its(united,dates=alldates) return(result) } ##daysecondIts-function---------------------------------------------- daysecondIts <- function (x,...) { if (!inherits(x, "its")) stop("function is only valid for objects of class 'its'") hour <- as.POSIXlt(x@dates,...)$hour min <- as.POSIXlt(x@dates,...)$min sec <- as.POSIXlt(x@dates,...)$sec return(3600 * hour + 60 * min + sec) } ##weekdayIts-function------------------------------------------------ weekdayIts <- function (x,...) { if (!inherits(x, "its")) stop("function is only valid for objects of class 'its'") day <- as.POSIXlt(x@dates,...)$wday return((0 < day) & (day < 6)) } ##rangeIts-function-------------------------------------------------- rangeIts <- function(x,start=dates(x)[1],end=dates(x)[nrow(x)],format=its.format(),...) { if (!inherits(x, "its")) stop("function is only valid for objects of class 'its'") if(mode(start)=="character") {start <- as.POSIXct(x=strptime(start,format=format),...)} if(mode(end)=="character") {end <- as.POSIXct(x=strptime(end,format=format),...)} if(!is(start,"POSIXt")) stop("start should be in POSIX format") if(!is(end,"POSIXt")) stop("end should be in POSIX format") start <- as.POSIXct(start) end <- as.POSIXct(end) return(x[which((x@dates>=start) & (x@dates<=end)),]) } ##newIts-function---------------------------------------------------- newIts <- function(x=NA, start=format(Sys.Date(),format=its.format()), end, ncol=1, by="DSTday", extract=FALSE, format=its.format(), tz="", ...) { if(mode(start)=="character") { start.p <- as.POSIXct(x=strptime(start,format=format),tz=tz) } else { start.p <- as.POSIXct(start) } if(missing(end)) { end <- format(as.Date(start,format=its.format()) + 99,format=its.format()) end.p <- as.POSIXct(x=strptime(end,format=format),tz=tz) } else if(mode(end)=="character") { end.p <- as.POSIXct(x=strptime(end,format=format),tz=tz) } else { end.p <- as.POSIXct(end) } dates <- seq(from=start.p,by=by,to=end.p) if(extract) { dates <- extractDates(dates=dates,...) } result <- its(matrix(x,ncol=ncol,nrow=length(dates)),dates) return(result) } ##extractIts-function----------------------------------------------- extractIts <- function(x, weekday=FALSE, find=c("all","last","first"), period=c("week","month","year"), partials=TRUE, firstlast=FALSE, select) { if (!inherits(x, "its")) stop("function is only valid for objects of class 'its'") xdates <- extractDates(x@dates, weekday=weekday, find=find, period=period, partials=partials, firstlast=firstlast, select=select) return(x[dates=xdates]) } ##collapse-function--------------------------------------------------- collapseIts <- function(x) { if (!inherits(x, "its")) stop("function is only valid for objects of class 'its'") labels <- dimnames(x)[[2]] uniquelabels <- unique(labels) jresult <- match(uniquelabels,labels) result <- x[,jresult]*NA if(length(uniquelabels)0)) stop("column data must match in collapse function") result[,j] <- apply(x[,jall],1,median,na.rm=TRUE) } } else { result <- x } return(result) } ##-Utilities-############################################################################################################## ##-Utility Methods- ##validity check---------------------------------------------------- validIts <- function(object) { if(!identical(nrow(object@.Data),length(object@dates))) return("Inconsistent length of dates") if(any(is.na(object@dates))) return("Missing values in dates") d <- diff(object@dates) if(any(d<0)) return("Dates must be non-decreasing") ##if(!is.null(attr(object@dates,"tzone"))) return("Timezone attribute not allowed in dates slot of class its") return(TRUE) } setValidity("its",validIts) ##[-method----------------------------------------------------------- subsetIts <- function(x, i, j, ..., drop=FALSE) { if(match("dates",names(list(...)),0)>0) { dates <- list(...)[["dates"]] if(!missing(i)) stop("cannot specify both dates and i") if(!is(dates,"POSIXt")) stop("dates should be in POSIX format") dates <- as.POSIXct(dates) i <- match(dates, dates(x)) if(any(is.na(i))) stop("some dates are not found") } if(missing(drop)) { drop <- FALSE } if(missing(i)) { i <- min(1,nrow(x)):nrow(x) } if(missing(j)) { j <- min(1,ncol(x)):ncol(x) } subx <- x@.Data[i, j, drop = drop] dates <- x@dates[i] ans <- new("its", subx, dates=dates) return(ans) } setMethod("[", c("its","ANY"),subsetIts) ##"[<-"-method----------------------------------------------------------- subset.replaceIts <- function(x, i, j, ..., value) { if(match("dates",names(list(...)),0)>0) { dates <- list(...)[["dates"]] if(!missing(i)) stop("cannot specify both dates and i") if(!is(dates,"POSIXt")) stop("dates should be in POSIX format") dates <- as.POSIXct(dates) i <- match(dates, dates(x)) if(any(is.na(i))) stop("some dates are not found") } if(missing(i)) { i <- min(1,nrow(x)):nrow(x) } if(missing(j)) { j <- min(1,ncol(x)):ncol(x) } x@.Data[i, j] <- value@.Data x@dates[i] <- value@dates ans <- new("its", core(x), dates=dates(x)) return(ans) } setReplaceMethod("[", signature(x="its", value="its"),subset.replaceIts) ##-Utility Functions- ##addDimnames-function----------------------------------------------- addDimnames <- function(x) { if(is.null(dimnames(x))) {dimnames(x) <- list(NULL,NULL)} if(is.null(dimnames(x)[[1]])&(nrow(x)>0)) {dimnames(x)[[1]] <- 1:nrow(x)} if(is.null(dimnames(x)[[2]])&(ncol(x)>0)) {dimnames(x)[[2]] <- 1:ncol(x)} return(x) } ##gapIts-function--------------------------------------------------- gapIts <- function(x,y,maxgap) { if (!inherits(x, "its")&inherits(y, "its")) stop("function is only valid for objects of class 'its'") d1 <- as.numeric(x@dates) d2 <- as.numeric(y@dates) dd1 <- diff(d1) dd2 <- diff(d2) del1 <- min(d1)-max(d2) del2 <- min(d2)-max(d1) gap <- max(max(del1,del2),0) allrange <- range(range(dd1),range(dd2)) gapwrong <- gap>max(allrange[2],maxgap) attr(gap,which="gapexcessive") <- gapwrong return(gap) } ##overlapsIts-function---------------------------------------------- overlapsIts <- function(x,y) { if (!inherits(x, "its") & inherits(y, "its")) stop("function is only valid for objects of class 'its'") if(max(as.numeric(x@dates))min(as.numeric(xhigh@dates))) stop("appendor data must extend appendee data") lowoverlap <- which(as.numeric(xlow@dates)>=min(as.numeric(xhigh@dates))) highoverlap <- which(as.numeric(xhigh@dates)<=max(as.numeric(xlow@dates))) if(!identical(xlow@dates[lowoverlap],xhigh@dates[highoverlap])) { mymatch <- FALSE } else { mymatch <- identical(all.equal(xlow[lowoverlap,],xhigh[highoverlap,]),TRUE) } return(mymatch) } ##namesmatchIts-function-------------------------------------------- namesmatchIts <- function(x,y) { lut <- match(dimnames(y)[[2]],dimnames(x)[[2]]) namesmatch <- identical(dimnames(x[,lut])[[2]],dimnames(y)[[2]])& all(!duplicated(dimnames(x)[[2]]))&all(!duplicated(dimnames(y)[[2]])) attr(namesmatch,which="lut") <- lut return(namesmatch) } ##its.format-function------------------------------------------------ its.format <- function(formatDefault=NULL) { if(is.null(formatDefault)) { outformat <- get(x=".itsformat",env=itsState,inherits=FALSE) } else { outformat <- formatDefault assign(x=".itsformat",value=formatDefault,env=itsState,inherits=FALSE) } return(outformat) } ##expandIts-function------------------------------------------------ expandIts <- function(x) { ##takes a single column 'its', if there are NAs, splits it into columns ##each column having only a single run of non-NA data if(all(is.na(x))) return(x) mat <- rbind(x[1,1,drop=FALSE]*NA,x[,1,drop=FALSE],x[nrow(x),1,drop=FALSE]*NA) ib <- which(diff(is.na(mat))==-1) ie <- which(diff(is.na(mat))==1) nruns <- length(ib) matexp <- matrix(NA,nrow=nrow(x),ncol=nruns) for(i in 1:nruns) { irun <- ib[i]:(ie[i]-1) matexp[irun,i] <- x[irun,1,drop=FALSE] } dimnames(matexp) <- list(dimnames(x)[[1]],rep(dimnames(x)[[2]][1],nruns)) result <- its(matexp,x@dates) result } ##extractDates-function---------------------------------------------- extractDates <- function(dates, weekday=FALSE, find=c("all","last","first"), period=c("week","month","year"), partials=TRUE, firstlast=FALSE, select) { find <- match.arg(find) period <- match.arg(period) myindex1 <- 1:length(dates) ##1 optionally point only to weekdays if(weekday) { wday <- as.POSIXlt(dates)$wday myindex1 <- which( (0 < wday) & (wday < 6) ) } if(period=="month") { theperiod <- 100*as.POSIXlt(dates[myindex1])$year+as.POSIXlt(dates[myindex1])$mon dayinperiod <- as.POSIXlt(dates[myindex1])$mday } else if(period=="year") { theperiod <- as.POSIXlt(dates[myindex1])$year dayinperiod <- as.POSIXlt(dates[myindex1])$yday } else if(period=="week") { theweek <- as.numeric(format(as.POSIXct(dates[myindex1]), "%U") ) theyear <- as.numeric(format(dates[myindex1],"%Y")) incorrectPartialWeek <- theweek==0 theyear[incorrectPartialWeek] <- theyear[incorrectPartialWeek]-1 ##first partial week in January assigned to last year theweek[incorrectPartialWeek] <- as.numeric(format(ISOdate(theyear[incorrectPartialWeek]-1,12,31),"%U")) ##only incomplete Jan weeks are indexed 0 (see Jan 1995) theperiod <- 100*theyear+theweek dayinperiod <- as.POSIXlt(dates[myindex1])$wday } ##2 if selecting based on 'find' if(find=="all") { myindex2 <- 1:length(myindex1) } else { myindex2 <- setdiff(which(diff(c(theperiod[1],theperiod))!=0),1) if(find=="last") { myindex2 <- myindex2-1 } if(partials) { if(find=="last") { myindex2 <- unique(c(myindex2,length(myindex1))) } else { myindex2 <- unique(c(1,myindex2)) } } } ##3 select based on 'select' if(missing(select)) { myindex3 <- 1:length(myindex2) } else { myindex3 <- which(dayinperiod[myindex2]%in%select) } myindex <- myindex1[myindex2][myindex3] if(firstlast) { myindex <- unique(c(1,myindex,myindex1[length(myindex1)])) } if(all(is.na(myindex))) myindex <- NULL return(dates[myindex]) } ##gencurves-function---------------------------------------------- gencurves <- function(x) { curves <- vector("list",(ncol(x))) for (j in 1:ncol(x)) { curves[[j]] <- list(x=as.numeric(x@dates),y=as.numeric(x[,j]@.Data)) } return(curves) } ##most.recent-function-------------------------------------------- most.recent <- function(x) { ## return a vector of indices of the most recent TRUE value (thanks to Tony Plate) if (!is.logical(x)) stop("x must be logical") x.pos <- which(x) if (length(x.pos)==0 || x.pos[1] != 1) x.pos <- c(1, x.pos) rep(x.pos, c(diff(x.pos), length(x) - x.pos[length(x.pos)] + 1)) } ##locf-function--------------------------------------------------- locf <- function(x) { if (!inherits(x, "its")) stop("function is only valid for objects of class 'its'") y <- x jna <- which(apply(is.na(x),2,any)) for(j in jna) { y[,j] <- y[most.recent(!is.na(y[,j])),j] } dates(y) <- dates(x) return(y) } ##priceIts-function------------------------------------------------- priceIts <- function (instruments = "^gdaxi", start, end, quote = c("Open","High", "Low", "Close"), provider = "yahoo", method = "auto", origin = "1899-12-30", compression="d", quiet=TRUE) ## added new argument, compression ## may be "d", "w" or "m", for daily weekly or monthly ## John Bollinger, 2004-10-20, www.BollingerBands.com, bbands@yahoo.com { if (provider != "yahoo") stop("provider not implemented") allinstruments <- NULL if (missing(start)) start <- "1991-01-02" if (missing(end)) end <- format(Sys.time() - 86400, "%Y-%m-%d") provider <- match.arg(provider) start <- as.POSIXct(start, tz = "GMT") end <- as.POSIXct(end, tz = "GMT") for(i in 1:length(instruments)) { url <- paste("http://chart.yahoo.com/table.csv?s=", instruments[i], format(start, paste("&a=", as.character(as.numeric(format(start, "%m")) - 1), "&b=%d&c=%Y", sep = "")), format(end,paste("&d=", as.character(as.numeric(format(end,"%m")) - 1), "&e=%d&f=%Y", sep = "")), "&g=",compression, "&q=q&y=0&z=", instruments[i], "&x=.csv", sep = "") destfile <- tempfile() status <- download.file(url, destfile, method = method, quiet=quiet) if (status != 0) { unlink(destfile) stop(paste("download error, status", status)) } nlines <- length(count.fields(destfile, sep = "\n")) if (nlines == 1) { unlink(destfile) stop(paste("No data available for", instruments[i])) } data <- read.csv(destfile) data <- data[nrow(data):1,] ## and inverse order in data y <- its(as.matrix(data[,-1]), dates=strptime(as.character(data[,1]), format="%Y-%m-%d")) oneinstrument <- its(y)[,quote] names(oneinstrument) <- paste(instruments[i],quote) allinstruments <- union(allinstruments,oneinstrument) } return(allinstruments) } its/man/0000755000175100001440000000000011251000546011634 5ustar hornikusersits/man/its-class.Rd0000644000175100001440000001004311250465002014024 0ustar hornikusers\name{its-class} \docType{class} \alias{its-class} \alias{Arith,its,its-method} \alias{Arith,its,numeric-method} \alias{Arith,numeric,its-method} \alias{[,its-method} \alias{[<-,its,ANY,ANY,its-method} \alias{coerce,its,data.frame-method} \alias{core,its-method} \alias{core<-,its,matrix-method} \alias{cumsum,its-method} \alias{dates,its-method} \alias{dates<-,its,POSIXt-method} \alias{diff,its-method} \alias{end,its-method} \alias{intersect,its,its-method} \alias{intersect,its,NULL-method} \alias{intersect,NULL,its-method} \alias{names,its-method} \alias{names<-,its,character-method} \alias{plot,its,missing-method} \alias{print,its-method} \alias{start,its-method} \alias{summary,its-method} \alias{union,its,its-method} \alias{union,its,NULL-method} \alias{union,NULL,its-method} \title{Class "its" Irregularly Spaced Time-Series } \description{ S4 class implementation of irregularly spaced time seires. The class implements Arith methods using date matching, union, intersection, and other time series methods. } \section{Objects from the Class}{ Objects can be created by calls of the form \code{new("its", ...)}. ~~ describe objects here ~~ } \section{Slots}{ \describe{ \item{\code{.Data}:}{Object of class \code{"matrix"} the data portion of the time series } \item{\code{dates}:}{Object of class \code{"POSIXt"} the date vector portion of the time series } } } \section{Extends}{ Class \code{"\linkS4class{matrix}"}, from data part. Class \code{"\linkS4class{structure}"}, by class "matrix", distance 2. Class \code{"\linkS4class{array}"}, by class "matrix", distance 2. Class \code{"\linkS4class{vector}"}, by class "matrix", distance 3, with explicit coerce. Class \code{"\linkS4class{vector}"}, by class "matrix", distance 4, with explicit coerce. } \section{Methods}{ \describe{ \item{Arith}{\code{signature(e1 = "its", e2 = "its")}: method for Arith of its and its } \item{Arith}{\code{signature(e1 = "its", e2 = "numeric")}: method for arith of its and numeric } \item{Arith}{\code{signature(e1 = "numeric", e2 = "its")}: method for arith of numeric and its } \item{[}{\code{signature(x = "its")}: subset operator for its } \item{[<-}{\code{signature(x = "its", i = "ANY", j = "ANY", value = "its")}: subset assignment operator for its } \item{coerce}{\code{signature(from = "its", to = "data.frame")}: coerce its to data.frame } \item{core}{\code{signature(x = "its")}: extract numeric portion of its } \item{core<-}{\code{signature(x = "its", value = "matrix")}: assignment to numeric portion of its } \item{cumsum}{\code{signature(x = "its")}: cumulative sum of its series } \item{dates}{\code{signature(x = "its")}: extract dates vector from its object } \item{dates<-}{\code{signature(x = "its", value = "POSIXt")}: assign dates into its object } \item{diff}{\code{signature(x = "its")}: difference function for its } \item{end}{\code{signature(x = "its")}: ... } \item{intersect}{\code{signature(x = "its", y = "its")}: take date intersection of its object } \item{intersect}{\code{signature(x = "its", y = "NULL")}: ... } \item{intersect}{\code{signature(x = "NULL", y = "its")}: ... } \item{names}{\code{signature(x = "its")}: extract column names from its object } \item{names<-}{\code{signature(x = "its", value = "character")}: assign names into its object } \item{plot}{\code{signature(x = "its", y = "missing")}: plot an its object } \item{print}{\code{signature(x = "its")}: print an its object } \item{start}{\code{signature(x = "its")}: ... } \item{summary}{\code{signature(object = "its")}: summary of an its object } \item{union}{\code{signature(x = "its", y = "its")}: combine its objects } \item{union}{\code{signature(x = "its", y = "NULL")}: ... } \item{union}{\code{signature(x = "NULL", y = "its")}: ... } } } \references{ http://code.google.com/p/rits } \author{ Whit Armstrong } \note{ This package was written by Giles Heywood. } \examples{ showClass("its") } \keyword{classes} its/man/dates.Rd0000644000175100001440000000070411250465002013225 0ustar hornikusers\name{dates} \alias{dates} \alias{dates<-} \title{Extract dates from object or assign dates to object.} \description{Extract dates from objects. Particularly time series objects.} \usage{ dates(x, ...) dates(x) <- value } \arguments{ \item{x}{ an object which contains dates } \item{value}{ new dates to be assigned to object } \item{\dots}{ further arguments to function } } \value{ a vector of dates } \author{ Whit Armstrong } \keyword{ts} its/man/itsJoin.rd0000644000175100001440000000365511250465002013614 0ustar hornikusers\keyword{ts} \name{itsJoin} \alias{itsJoin} \alias{alignedIts} \alias{appendIts} \alias{collapseIts} \title{Join Functions for Irregular Time-Series Objects} \description{ Join functions for objects of class \code{"its"}. } \usage{ alignedIts(obj1,obj2,print=FALSE) appendIts(obj1,obj2,but=TRUE,matchnames=TRUE) collapseIts(x) } \arguments{ \item{x}{an object of class \code{"its"} or NULL} \item{obj1,obj2}{object of class \code{"its"}} \item{print}{logical flag to display summary information} \item{but}{logical flag controls whether overlap is disallowed} \item{matchnames}{logical flag controls whether names must match} } \details{ \code{alignedIts} selects the rows from two inputs which have identical time-stamps. \code{appendIts} appends one object to the other, removing overlapping data from the later object, optionally checking that the column names match. Overlapping data must match. \code{collapseIts} checks for columns with the same names, using dimnames(x)[[2]]. columns with the same names are required to have the same numeric values in each row, but are allowed NAs. The numeric data is combined, and the resulting object has unique column names - this will in general result in a reduction in the number of columns. } \value{ For \code{appendIts} an object of class \code{"its"}. For \code{alignedIts}, a list of two objects of class \code{"its"} } \author{Giles Heywood} \seealso{ \code{\link{ts}}, \code{\link{POSIXct}}, \code{\link{itsFile}}, \code{\link{itsLags}}, \code{\link{itsJoin}}, \code{\link{itsTimes}}, \code{\link{itsSubset}}, \code{\link{itsFin}}, \code{\link{itsInterp}} } \examples{ its.format("\%Y-\%m-\%d") b <- newIts(1:30,ncol=3,start="2003-01-01",end="2003-01-10") union(b,diff(b)) intersect(b,diff(b)) alignedIts(b,diff(b)) b1 <- newIts(1:30,ncol=3,start="2003-01-11",end="2003-01-20") appendIts(b,b1) c <- union(b,b*NA) c[2,4] <- 99 c[2,1] <- NA print(c) collapseIts(c) } its/man/itsDef.rd0000644000175100001440000001371111251000546013404 0ustar hornikusers\keyword{ts} \name{itsDef} \alias{its} \alias{is.its} \alias{as.its} \alias{as.its.default} \alias{as.its.zoo} \alias{its.format} \alias{newIts} \title{Irregularly Spaced Time-Series} \description{ The function \code{its} is used to create irregular time-series objects from user-supplied data and time-stamps. \code{newIts} is used to create semi-regular time-series objects from user-supplied data, and rule for generating time-stamps. \code{as.its} coerces an object to an irregularly spaced time-series. \code{is.its} tests whether an object is an irregularly spaced time series. } \usage{ its(x, dates=as.POSIXct(x=strptime(dimnames(x)[[1]],format=its.format())), names=dimnames(x)[[2]], format=its.format(),...) newIts(x=NA,start=format(Sys.Date(),format=its.format()), end,ncol=1,by="DSTday",extract=FALSE,format=its.format(),tz="",...) as.its(x,...) is.its(object) its.format(formatDefault=NULL) } \arguments{ \item{dates}{a vector of class \code{"POSIXct"} representing the time-stamps of the irregular time-series object. The elements of the numeric vector are construed as the number of seconds since the beginning of 1970, see \code{\link{POSIXct}}.} \item{start, end}{POSIXct or character representation of the start or end time-stamp, if character, then the format is as specified by the argument \code{format}} \item{ncol}{number of columns of synthetic sequence of dates} \item{by}{time increment for synthetic sequence of dates, see \code{\link{seq.POSIXt}}} \item{extract}{logical flag: if TRUE, a subset of the synthetic sequence of dates is extracted, see \code{\link{extractIts}}} \item{x}{a numeric matrix representing the values of the irregular time-series object. In the case of coercion in as.its, the first column is taken to be the time-stamps, in seconds since the beginning of 1970, see \code{\link{POSIXct}}.} \item{object}{an R object convertible to its} \item{names}{a vector of mode character} \item{format}{a formatting string, see \code{\link{format.POSIXct}}, defaults to \code{its.format()}} \item{formatDefault}{a formatting string, see \code{\link{format.POSIXct}}, defaults to \code{"\%Y-\%m-\%d"} if \code{formatDefault} is not specified.} \item{tz}{time zone of dates of its object} \item{\dots}{further arguments passed to or from other methods: for \code{its} passed to \code{\link{format.POSIXct}}.; for \code{as.its} passed to \code{\link{its}}.; for \code{newIts} passed to \code{\link{extractIts}}.} } \details{ The function \code{its} is used to create irregular time-series objects, which have (S4) class "its". An object of class "its" is a matrix with rows indexed by a time-stamp of class "POSIXct". Unlike objects of class "ts", it can be used to represent irregularly spaced time-series. The object consists of a matrix, with a single slot, the named POSIX vector named "dates". An object of class "its" inherits matrix arithmetic methods. The matrix has dimnames: dimnames[[1]] is populated with a text representation of "dates", using a format which is defined by the function its.format. These dates are not used in computations - all computations use the POSIX representation. The dates are required to be in ascending order. When matrix multiplication is applied to an "its", the result is of class matrix. It is possible to restore the "its" class (see examples) - its() is in this sense idempotent i.e. its(mat)==its(its(mat)). Note however that the dates will be taken from dimnames[[1]], so the accuracy of this operation depends on the format of the dates. \code{newIts} is a utility for creating a new "its" using a series of 'semi-regular' time-stamps, such as weekday, weekly, monthend etc. Conceptually the date sequence generation has two parts. The first part is the generation of a sequence using \code{\link{seq.POSIXt}} - the arguments from, to, and by are passed to this function. The second part (which is optional, and applies only if extract=TRUE) is an extraction, performed by \code{extractIts}. See \code{\link{extractIts}} for details of the arguments, which are passed via '...' . The function \code{its.format} assigns a private variable and returns its value. The value of this default format persists in the session until reset. The purpose of the function is one of convenience: to access and/or assign the default text format for dates in the "its" package, and hence reduce the need to define the format repeatedly in a session. } \value{ For \code{its}, \code{newIts} and \code{as.its}, an object of class \code{"its"}, inheriting from matrix, with a single slot named \code{'dates'}, which is a vector of class \code{POSIXct} For \code{is.its}, a logical representing the result of a test for class membership For \code{its.format}, a text representation of dates formatting to be used in the "its" package, see \code{\link{format.POSIXct}} } \author{Giles Heywood} \seealso{ \code{\link{ts}}, \code{\link{POSIXct}}, \code{\link{itsFile}}, \code{\link{itsLags}}, \code{\link{itsJoin}}, \code{\link{itsTimes}}, \code{\link{itsSubset}}, \code{\link{itsFin}}, \code{\link{itsInterp}} } \examples{ its.format("\%Y-\%m-\%d") #defines text format of dates read from dimnames mat <- structure(1:6,dim=c(2,3),dimnames=list(c("2003-01-01","2003-01-04"),letters[1:3])) its(mat) its.format("\%Y\%m\%d") #defines text format of dates written to dimnames times <- as.POSIXct(strptime(c("1999-12-31 01:00:00","2000-01-01 02:00:00"),format="\%Y-\%m-\%d \%X")) its(mat,times) its.format("\%Y-\%m-\%d \%X") its(mat,times) is.its(its(mat,times)) its.format("\%Y\%m\%d \%X") #defines text format of dates written to dimnames as.its(mat) its.format("\%a \%d \%b \%Y") newIts(start="2003-09-30",end="2005-05-05",format="\%Y-\%m-\%d",period="month",find="last",extract=TRUE,weekday=TRUE) newIts(start=ISOdate(2003,12,24,0),end=ISOdate(2004,1,10),extract=TRUE,weekday=TRUE) its.format("\%Y\%m\%d") as(newIts(),"data.frame") } its/man/core.Rd0000644000175100001440000000066311250465002013061 0ustar hornikusers\name{core} \alias{core} \alias{core<-} \title{Extract core from object or assign core to object} \description{Extract core from objects. Particularly time series objects.} \usage{ core(x) core(x) <- value } \arguments{ \item{x}{ an object which contains core } \item{value}{ new core to be assigned to object } \item{\dots}{ further arguments to function } } \value{ a vector of core } \author{ Whit Armstrong } \keyword{ts} its/man/itsInterp.rd0000644000175100001440000000146011250465002014146 0ustar hornikusers\keyword{ts} \name{itsInterp} \alias{itsInterp} \alias{locf} \title{Interpolation Functions for Irregular Time-Series Objects} \description{ Interpolation functions for objects of class \code{"its"}. } \usage{ locf(x) } \arguments{ \item{x}{an object of class \code{"its"} or NULL} } \details{ \code{locf} 'Last Observation Carry Forward'. NAs are replaced by the last preceding valid observation within the series. } \value{ An object of class \code{"its"}. } \author{Giles Heywood} \seealso{ \code{\link{ts}}, \code{\link{POSIXct}}, \code{\link{itsFile}}, \code{\link{itsLags}}, \code{\link{itsJoin}}, \code{\link{itsTimes}}, \code{\link{itsSubset}}, \code{\link{itsFin}}, } \examples{ x <- newIts(11:40,ncol=3) x[1:2,1] <- NA x[3:4,2] <- NA x[9:10,3] <- NA print(x) print(locf(x)) } its/man/itsFin.rd0000644000175100001440000000201611250465002013417 0ustar hornikusers\keyword{ts} \name{itsFin} \alias{itsFin} \alias{accrueIts} \title{Financial Functions for Irregular Time-Series Objects} \description{ Financial functions for objects of class \code{"its"}. } \usage{ accrueIts(x,daysperyear=365) } \arguments{ \item{x}{an object of class \code{"its"}} \item{daysperyear}{integer, representing days per year for accrual} } \details{ \code{accrueIts} Accrues an annual rate stored in x, expressed as a decimal (not a percentage), based on the difference of the time-stamps. The accrued value is not cumulated, it is a per-period return. } \value{ An object of class \code{"its"} } \author{Giles Heywood} \seealso{ \code{\link{ts}}, \code{\link{POSIXct}}, \code{\link{itsFile}}, \code{\link{itsLags}} \code{\link{itsJoin}} \code{\link{itsTimes}} \code{\link{itsSubset}} \code{\link{itsFin}} \code{\link{itsInterp}} } \examples{ a <- matrix(c(seq(by=24*60*60,length=20),1:20,41:60),nrow=20,ncol=3) b <- as.its(a) accrueIts(b[which(weekdayIts(b)),]/100,daysperyear=365) } its/man/itsTimes.rd0000644000175100001440000000223011250465002013762 0ustar hornikusers\keyword{ts} \name{itsTimes} \alias{itsTimes} \alias{daysecondIts} \alias{weekdayIts} \title{Time Functions for Irregular Time-Series Objects} \description{ Time functions for objects of class \code{"its"}. } \usage{ daysecondIts(x,...) weekdayIts(x,...) } \arguments{ \item{x}{an object of class \code{"its"}} \item{\dots}{further arguments passed to \code{\link{as.POSIXlt}}} } \details{ \code{daysecondIts} returns the number of seconds since midnight. \code{weekdayIts} tests which entries of an irregular time-series object are time-stamped with weekdays. } \value{ For \code{daysecondIts} a vector of decimal numbers representing the number of seconds. For \code{weekdayIts} a vector of \code{"logical"} representing the test results for each time. } \author{Giles Heywood} \seealso{ \code{\link{ts}}, \code{\link{POSIXct}}, \code{\link{itsFile}}, \code{\link{itsLags}} \code{\link{itsJoin}} \code{\link{itsTimes}} \code{\link{itsSubset}} \code{\link{itsFin}} \code{\link{itsInterp}} } \examples{ \dontrun{ its.format("\%Y-\%m-\%d \%A") b <- newIts() print(b) daysecondIts(b) weekdayIts(b) its.format("\%Y-\%m-\%d") } } its/man/itsDownload.rd0000644000175100001440000000552711250465002014464 0ustar hornikusers\keyword{ts} \name{priceIts} \alias{priceIts} \title{Download Historical Finance Data} \description{ Download historical financial data from a given data provider over the WWW. } \usage{ priceIts(instruments = "^gdaxi", start, end, quote = c("Open","High", "Low", "Close"), provider = "yahoo", method = "auto", origin = "1899-12-30", compression = "d", quiet=TRUE) } \arguments{ \item{instruments}{a character string giving the name of the quote symbol to download. See the web page of the data provider for information about the available quote symbols.} \item{start}{an R object specifying the date of the start of the period to download. This must be in a form which is recognized by \code{\link{as.POSIXct}}, which includes R POSIX date/time objects, objects of class \code{"date"} (from package \code{date}) and \code{"chron"} and \code{"dates"} (from package \code{chron}), and character strings representing dates in ISO 8601 format. Defaults to 1992-01-02.} \item{end}{an R object specifying the end of the download period, see above. Defaults to yesterday.} \item{quote}{a character string or vector indicating whether to download opening, high, low, or closing quotes, or volume. For the default provider, this can be specified as \code{"Open"}, \code{"High"}, \code{"Low"}, \code{"Close"}, and \code{"Volume"}, respectively. Abbreviations are allowed.} \item{provider}{a character string with the name of the data provider. Currently, only \code{"yahoo"} is implemented. See \url{http://quote.yahoo.com/} for more information.} \item{method}{tool to be used for downloading the data. See \code{\link{download.file}} for the available download methods.} \item{origin}{an R object specifying the origin of the Julian dates, see above. Defaults to 1899-12-30 (Popular spreadsheet programs internally also use Julian dates with this origin).} \item{quiet}{a flag to suppress output} \item{compression}{Governs the granularity of the retrieved data; "d" for daily, "w" for weekly or "m" for monthly. Defaults to "d".} } \value{ An \code{"its"} object with the requested data } \details{ This function is a direct copy from package \code{tseries}, and all credit must go to the author of that package. } \author{A. Trapletti [*not* responsible for errors, adapted from his original idea by Giles Heywood]} \seealso{ \code{\link{ts}}, \code{\link{as.POSIXct}}, \code{\link{download.file}}; \url{http://quote.yahoo.com/} } \examples{ \dontrun{ x1 <- priceIts(instrument = c("^ftse"), start = "1998-01-01", quote = "Close") x2 <- priceIts(instrument = c("^gdax"), start = "1998-01-01", quote = "Close") x <- union(x1,x2) names(x) <- c("FTSE","DAX") plot(x,lab=TRUE) } } its/man/itsConvert.rd0000644000175100001440000000133011250465002014321 0ustar hornikusers\keyword{ts} \name{itsConvert} \alias{itsConvert} \alias{as.data.frame.its} \alias{as.list.its} \title{Conversion for its objects} \description{ Conversions to basic types for \code{"its"}. } \usage{ as.list.its(x,...) as.data.frame.its(x, row.names = NULL, optional = FALSE,...) } \arguments{ \item{x}{an object of class \code{"its"}} \item{\dots}{further arguments} \item{row.names}{character vector giving the row names for the data frame.} \item{optional}{logical. If 'TRUE', setting row names and converting column names (to syntactic names) is optional.} } \details{ Conversion ot basic types } \value{ For \code{as.list.its} a list for \code{as.data.frame.its} a data frame } \author{Gabor Grothendieck} its/man/itsFile.rd0000644000175100001440000000416711250465002013573 0ustar hornikusers\keyword{ts} \name{itsFile} \alias{itsFile} \alias{readcsvIts} \alias{writecsvIts} \title{File Operations for Irregular Time-Series Objects} \description{ File read and write operations for objects of class \code{"its"}. } \usage{ readcsvIts(filename,informat=its.format(),outformat=its.format(),tz="",usetz = FALSE,header=TRUE,...) writecsvIts(x,filename,format=its.format(),tz="",usetz = FALSE,col.names=NA, sep=",",split=FALSE,...) } \arguments{ \item{filename}{filename} \item{x}{an object of class \code{"its"}} \item{format, informat, outformat}{formatting related arguments, see \code{\link{format.POSIXct}}.} \item{tz}{what timezone the its is in} \item{usetz}{whether to include the tzone information in the saved file} \item{header}{see \code{\link{read.csv}}} \item{col.names, sep}{see \code{\link{write.table}}} \item{split}{when columns exceed 255 in number, flags for splitting into numbered subfiles} \item{\dots}{further arguments passed to or from other methods: for \code{readcsvIts} passed to \code{\link{read.csv}}; for \code{writecsvIts} passed to \code{\link{write.table}}} } \details{ \code{readcsvIts} reads from a .csv file to a matrix. The first column is assumed to contain dates in text format specified by informat, which can optionally be reformatted into the text format outformat. Both of these formats default to the format specified by \code{\link{its.format}}. To convert the matrix to an its, use \code{\link{its}} (see example) \code{writecsvIts} write an irregular time-series object to a text file. } \value{ For \code{readcsvIts} a matrix } \author{Giles Heywood} \seealso{ \code{\link{ts}}, \code{\link{POSIXct}}, \code{\link{itsFile}}, \code{\link{itsLags}} \code{\link{itsJoin}} \code{\link{itsTimes}} \code{\link{itsSubset}} \code{\link{itsFin}} \code{\link{itsInterp}} } \examples{ \dontrun{ b <- newIts(1:30,ncol=3) fname <- tempfile() # To write an irregular time-series object to a file one might use writecsvIts(b,filename=fname) # To read an irregular time-series object from a file one might use its(readcsvIts(filename=fname)) unlink(fname) } } its/man/itsLags.rd0000644000175100001440000000170411250465002013574 0ustar hornikusers\keyword{ts} \name{itsLags} \alias{itsLags} \alias{lagIts} \alias{lagdistIts} \title{Lag Functions for Irregular Time-Series Objects} \description{ Lag functions for objects of class \code{"its"}. } \usage{ lagIts(x,k=1) lagdistIts(x,kmin,kmax) } \arguments{ \item{x}{an object of class \code{"its"}} \item{k, kmin, kmax}{integer lag; positive value mean earlier data is assigned to a later timestamp} } \details{ \code{lagIts} returns an object with the same time-stamps, but with the data shifted. \code{lagdistIts} applies lagIts over a range of lags, and appends these columns } \value{ An object of class \code{"its"}. } \author{Giles Heywood} \seealso{ \code{\link{ts}}, \code{\link{POSIXct}}, \code{\link{itsFile}}, \code{\link{itsLags}} \code{\link{itsJoin}} \code{\link{itsTimes}} \code{\link{itsSubset}} \code{\link{itsFin}} \code{\link{itsInterp}} } \examples{ b <- newIts(1:10) lagIts(b) lagdistIts(b[,1],1,3) } its/man/itsSubset.rd0000644000175100001440000000531011250465002014150 0ustar hornikusers\keyword{ts} \name{itsSubset} \alias{itsSubset} \alias{rangeIts} \alias{extractIts} \title{Range and Extract for Irregular Time-Series Objects} \description{ Range and extract for objects of class \code{"its"}. } \usage{ rangeIts(x,start=dates(x)[1],end=dates(x)[nrow(x)],format=its.format(),...) extractIts(x,weekday=FALSE,find=c("all","last","first"),period=c("week","month","year"),partials=TRUE,firstlast = FALSE,select) } \arguments{ \item{x}{an object of class \code{"its"}} \item{start, end}{POSIXct or character representation of the start or end time-stamp, if character, then the format is as specified by the argument \code{format}} \item{format}{format of \code{"start"} and \code{"end"} dates, see \code{\link{format.POSIXct}}.} \item{dates}{POSIX dates specifying the timestamps of rows to be extracted from the irregular time-series object} \item{\dots}{further arguments passed to \code{\link{as.POSIXct}}} \item{weekday}{logical, defines whether only weekdays are to be returned} \item{find}{to find the first, last, or all samples within each period} \item{period}{the period within which 'find' and/or 'select' operate} \item{partials}{defines whether the first (possibly incomplete) period is processed for find=first, and whether the last is processed for find=last} \item{firstlast}{if TRUE, the first and last observations are returned, in addition to those observations selected by other criteria} \item{select}{an integer vector defining one or more days to select. The integer specifies \code{wday} (for period=week) or \code{mday} (for period=month). See \code{\link{as.POSIXlt}} for details} } \details{ \code{rangeIts} selects a range of rows that fall between two times, specified in text format. \code{extractIts} selects a subset of rows that obey some sort of semi-regular rule such as monthends, weekdays, and so on. The order of application is \code{weekday}, \code{find}, then \code{select}. } \value{ An object of class \code{"its"}. } \author{Giles Heywood} \seealso{ \code{\link{ts}}, \code{\link{POSIXct}}, \code{\link{itsFile}}, \code{\link{itsLags}}, \code{\link{itsJoin}}, \code{\link{itsTimes}}, \code{\link{itsSubset}}, \code{\link{itsFin}}, \code{\link{itsInterp}} } \examples{ its.format("\%Y-\%m-\%d") b <- newIts(start="2003-01-01",end="2003-01-20") rangeIts(b,start = "2003-01-05" ,end= "2003-01-15") rangeIts(b,start = ISOdate(2003,1,5,hour=0) ,end= ISOdate(2003,1,15,hour=0)) b[1:3,] b[,1] b[,dates=ISOdate(2003,1,1,hour=0,tz="")] its.format("\%a \%d \%b \%Y") c <- newIts() extractIts(c,weekday=TRUE,period="month",find="last") #the last weekdays of the month in c } its/COPYING0000644000175100001440000004311011250465002012114 0ustar hornikusers GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. its/NAMESPACE0000644000175100001440000000160411250465002012302 0ustar hornikusersimport(methods) import(stats) export( readcsvIts, writecsvIts, accrueIts, its, is.its, as.its, as.its.default, as.its.zoo, lagIts, lagdistIts, alignedIts, appendIts, daysecondIts, weekdayIts, rangeIts, newIts, extractIts, collapseIts, its.format, locf, priceIts, as.list.its, as.data.frame.its ) exportClasses("its") exportMethods( Arith, "[", names, "names<-", dates, "dates<-", core, "core<-", plot, print, start, end, summary, cumsum, diff, union, intersect, coerce )