How to use termstrc functions?
On Mar 20, 2009, at 10:15 AM, Chirantan Kundu wrote:
Here it goes -
library(termstrc)
ISIN <- vector()
ISIN[1]<-"IN0020080019"
ISIN[2]<-"IN0020020163"
MATURITYDATE<-as.Date(c("20081231","20101231"),"%Y%m%d")
STARTDATE<-as.Date(c("20010101","20020101"),format="%Y%m%d")
COUPONRATE<-c(8.24,7.95)
PRICE<-(50,100)
ACCRUED<-c(5,2)
TODAY<-c(Sys.Date(),Sys.Date())
mybonds <- list(ISIN,MATURITYDATE,STARTDATE,
COUPONRATE,PRICE,ACCRUED,TODAY)
names(mybonds) <- c("ISIN","MATURITYDATE","STARTDATE","COUPONRATE",
"PRICE","ACCRUED","TODAY")
allbonds <- list(mybonds)
names(allbonds)<-c("mybonds")
create_cashflows_matrix(allbonds)
I also tried -
library(termstrc)
data(corpbonds)
create_cashflows_matrix(corpbonds)
Your collection of bonds need to be organized in groups and the call to create_cashflows_matrix needs to call those groups by name. In the case of the corpbonds dataset, this call gets you output: create_cashflows_matrix( corpbonds$AAA )
David Winsemius > > > Both result into the same error - Error in as.vector(x, mode) : > invalid 'mode' argument. > Regards. > > On Fri, Mar 20, 2009 at 7:09 PM, David Winsemius <dwinsemius at comcast.net > > wrote: >> Got code? >> >> On Mar 20, 2009, at 8:15 AM, Chirantan Kundu wrote: >>> >>> I'm trying to use the package termstrc. However I cannot figure out >>> how to invoke helper functions like create_cashflows_matrix & >>> create_maturities_matrix. Even when I try to invoke those with the >>> data supplied with the package (say, corpbonds), it throws error >>> saying "Error in as.vector(x, mode) : invalid 'mode' argument". Can >>> anybody provide some working example for these? >>> I'm on Windows XP and using R-2.7.2 + termstrc 1.1. >>> >>> >>> PLEASE do read the posting guide >>> http://www.R-project.org/posting-guide.html >>> and provide commented, minimal, self-contained, reproducible code. >> >> David Winsemius, MD >> Heritage Laboratories >> West Hartford, CT >> >> > ____________________________________ > Visit us at http://www.2pirad.com > David Winsemius, MD Heritage Laboratories West Hartford, CT