
also Rory gave a simple way years ago:
Example:

> cf <- c(-10000, 1322, -1200, 12000)
> npv <- function(i, cf, t=seq(along=cf)) sum(cf/(1+i)^t)
> irr <- function(cf) { uniroot(npv, c(0,1), cf=cf)$root }
> irr(cf)
[1] 0.06937691
Best,Yihao



> From: aeolus_lu@hotmail.com
> To: qian@wealthfront.com; r-sig-finance@r-project.org
> Date: Thu, 23 Jun 2011 18:36:58 -0400
> Subject: Re: [R-SIG-Finance] Is there a function to calculate internal rate of return in R?
> 
> 
> http://albertosantini.blogspot.com/2008/01/xirr.html
> Best,
> Yihao
> 
> 
> 
> > Date: Thu, 23 Jun 2011 15:09:49 -0700
> > From: qian@wealthfront.com
> > To: r-sig-finance@r-project.org
> > Subject: [R-SIG-Finance] Is there a function to calculate internal rate of	return in R?
> > 
> > Hi,
> > 
> > I need to calculate the internal rate of return from cash flows, and wonder
> > if there's such a function in R. I did some internet search and haven't
> > found anything relevant.
> > 
> > Thanks!
> > 
> > Best,
> > Qian
> > 
> > 	[[alternative HTML version deleted]]
> > 
> > _______________________________________________
> > R-SIG-Finance@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> > -- Subscriber-posting only. If you want to post, subscribe first.
> > -- Also note that this is not the r-help list where general R questions should go.
>  		 	   		  
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-SIG-Finance@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
 		 	   		  
	[[alternative HTML version deleted]]

