[R] Strange error while passing string as an argument to the function in bnlearn package

Alexandr M rus314 at gmail.com
Mon Nov 10 18:46:45 CET 2014


Hello everybody,

I am working with the package bnlear, but, probably, error is caused not by
the package itself.

There is a function cpquery() to which I pass argument str2:

str2="(lag1=='s')"
prob.s = cpquery(fitted1,
                             event=eval(parse(text="(M=='s')")),
                             evidence=eval(parse(text=str2)))

- Error in parse(text = str2) : object 'str2' not found

fitted1 is a fitted model

But if I put value of str2 directly into function call:

prob.s = cpquery(fitted1,
                             event=eval(parse(text="(M=='s')")),
                             evidence="(lag1.M1=='s')")
it works fine.

Does anybody have any idea how to fix it?

PS:
- I used documentation to the package:
http://cran.r-project.org/web/packages/bnlearn/bnlearn.pdf
function cpquery()
- I also trued to use backslashes \' \" - doesn't work too

-- 
Best regards,
Alexandr

	[[alternative HTML version deleted]]



More information about the R-help mailing list