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

Marco Scutari marco.scutari at gmail.com
Tue Nov 11 00:28:49 CET 2014

Hi Alexandr,

On 10 November 2014 17:46, Alexandr M <rus314 at gmail.com> wrote:
> I am working with the package bnlear, but, probably, error is caused not by
> the package itself.

Logic sampling in cpquery() relies on handling unevaluated
expressions, so it is a tad fragile in any complex setting (inside
loops and function calls, for example). On its own, the
eval(parse(...)) trick works if you do it in the global environment,
or in relatively simple scripts.

For the simple query you are trying to do, just use likelihood weighting:

prob.s = cpquery(fitted1,
                             method = "lw")

passing str2 as a list.


Marco Scutari, Ph.D.
Lecturer in Statistics, Department of Statistics
University of Oxford, United Kingdom

More information about the R-help mailing list