Reputation: 11
I'm trying to calculate IRRs with cashflow datas that I have for my data's funds. I try this with following code:
install.packages("tvm")
library(dplyr)
library(tvm)
var1 <- my_data %>%
group_by(Fund_name) %>%
mutate(DATE = as.Date(DATE)) %>%
summarise(
IRR = xirr(cf =Cashflow, d = DATE,
tau = NULL, comp_freq = 12, interval = c(-1, 10)))
This however works for first 80 funds and then gives this error "Error in summarise()
:
! Problem while computing IRR = xirr(...)
.
ℹ The error occurred in group 81: NAME = "Fund81".
Caused by error in uniroot()
:
! no sign change found in 1000 iterations"
I'm wondering is there any way to get this code to skip errors and run the whole data so that the code wouldn't stop for the first error that it encounters? The code could for example return "error" for all the funds for which this code cannot calculate IRR. Thank you for help!
Upvotes: 1
Views: 46