query_averager <- function(arg1,
arg2) {
n = tibble()
i = 1
while (i <= 100) {
n[i] <- cpquery(fitted = fitted_bn_01,
event = (ret == "Acima da Selic") ,
evidence = (solidez == arg1) & (resultado == arg2))
i = i+1
}
return (mean(n))
}
Query_result <- query_averager(arg1 = "1", arg2 = "Lucro acima da mediana")
This gives me "object arg1 not found", but when I use the function cpquery()
outside, it works perfectly.
Working code without the query_averager function:
cpquery(fitted = fitted_bn_01,
event = (ret == "Acima da Selic") ,
evidence = (solidez == "1") & (resultado == "Lucro acima da median"))
I believe it doesn't matter what the other variables are, the main problem is why:
solidez == "1"
works and the code snippet below doesn't:
solidez == arg1