I am working in netlogo on a model which has to communicate with R during the run. I do this using the r extension in netlogo (so not Rnetlogo in R).
at the setup I load my script with
r:eval "source('C:/Users/keemi/OneDrive/Documenten/Thesis/heatpumps/scriptHeatpumpV1.R')"
this works fine since I can ask what I want coming from the script with this code. r:get "cpquery(fittedHeatpumpv1, event = (Reliability == 0.88), evidence = (Economic == 0.08))"
this gives me a chance percentage of the event given the evidence.
However the evidence must come from the netlogo network, I do this using
r:put "economicvalue" reliability
this creates a variable in r -> economicvalue from the value of reliability in netlogo (which is 0.08 for the example).
I then put in the following code r:get "cpquery(fittedHeatpumpv1, event = (Reliability == 0.88), evidence = (Economic == economicvalue))"
to get to the same result, however netlogo gives the error
Extension exception: Error in R-Extension: Error in Get.
org.nlogo.api.ExtensionException: Error in eval(evidence, generated.data, parent.frame()) :
object 'economicvalue' not found
error while company 157 running R:GET
called by procedure INVEST
called by procedure GO
called by Button 'go-once'
this is odd since if I do the same thing in r itself it works just fine. and the script itself also works fine since I can load things from it.
I also checked the value of the r:put and this was indeed set to 0.08 if I call it back using r:get "economicvalue"
I also tested it already without the variable coming from netlogo but just giving the command directly to r using r:eval "economicvalue <- 0.08"
but the same error occurs.
I can't figure out what I am doing wrong here, since the code works in r itself if I put the same code lines but not coming from netlogo, and netlogo also performs well since I can see if the r commands work with the r:get
and this all gives the right values.
could somebody help me out?