I have a problem while I am trying to call a R function I have created, in VBA. The problem does not come from the connection between VBA and R, but when my R code has to call my own function, the program stops. To make it clearer, here is the R code:
args = commandArgs(trailingOnly=T)
sink('Y:/Documents/BC10.txt', append=F, type = "output",split=TRUE)
source("Y:/Documents/myfunction.R")
cat('TEST !!')
simul = args[1]
level = args[2]
spd1 = args[3]
spd2 = args[4]
spd3 = args[5]
date_valo = toString(args[6])
swap_rate = args[7]
l1 = 0
u1 = 0.03
rho2 = 0.5
cat('\nparameters are: ', simul, level, spd1 , spd2, spd3, date_valo, swap_rate)
PV_eq=PV_eq=myfunction(l1,u1,spd1,rho2,simul,level, date_valo, swap_rate)
cat(PV_eq)
sink()
When I run my VBA code, the program does well concerning the display of the parameters in the text file "BC10.txt", but it does not display PV_eq. So, I supposed the program does not manage to call my user-defined function "myfunction".
Does anybody has an idea of the problem I encounter ? Maybe, I have to add something in my VBA code (or R code) so that VBA takes into account user-defined function ?