All,
I have been looking for a solution to handle XIRR calculation in JMP. In the process, @ron_horne was kind enough toi share some of his work.
I went down the path of leveraging some packages within R for the calculation. I have also put in a feature request for XIRR and XNPV functions to be deployed into future versions of JMP. However, the current problem that I have noticed is - the R package that I am leveraging is not yielding results I expect and it is kind of confusing me. Wondering if anyobdy like @ih or any other JMP users on the community have seen success going down this path or ventured out in a different direction with success for XIRR calculation.
RConn = R Connect();
ConnFlag = R Is Connected();
If(ConnFlag,
R Submit("
# Reprex
# Attach desired packages
suppressPackageStartupMessages(library(tvm))
# Provide input data
CF <- c(-78662, -32491, -32492, 7651, 40300)
d <- as.Date(c('2019-06-30', '2019-09-30', '2019-12-31', '2020-03-31', '2020-06-30'))
# Call the XIRR Function
Res1 <- vector()
Res1 <- sapply(1:length(d), function(i) {
tryCatch({
expr = xirr(i, CF[1:i],
d[1:i])
}, error = function(i) { return(NA) })
})
# Print Results
#print(Res1)
");
Results = R Get(Res1);
RConn << disconnect;
);
The above calculation should return NA until i = 4 , but once the cash flow sees a sign change - it should return a value other than NA as Excel would. Any thoughts or guidance to fix this is appreciated .