Thanks Marco, The cpquery function is definitely easier to use given that my evidence is contained in lists.
Thanks for your help! --- Ryan Ryan Morrison, PE PhD Candidate University of New Mexico Department of Civil Engineering Centennial Engineering Center, Room 3057 Phone: 505-633-5506 Email: rmorr...@unm.edu www.ryanmorrison.org On Oct 10, 2013, at 3:16 AM, Marco Scutari <marco.scut...@gmail.com> wrote: > Dear Ryan, > > On 9 October 2013 21:26, Ryan Morrison <ryan.r.morri...@me.com> wrote: >> I'm attempting to use the bnlearn package to calculate conditional >> probabilities, and >> I'm running into a problem when the "cpquery" function is used within a >> loop. I've >> created an example, shown below, using data included with the package. When >> using the cpquery function in a loop, a variable created in the loop ("evi" >> in the >> example) is not recognized by the function. I receive the error: >> >> Error in parse(text = evi) : object 'evi' not found > [snip] > > Based on the second example you emailed me off-list, it appears to be > a scoping problem; that's why the same code works if it's not inside a > function. I will try to debug this soon, but I am not an expert in R > parsing mechanisms so it will take some time. In the mean time, you > can use cpquery(..., method = "lw") instead of the default > cpquery(..., method = "ls") if your query looks like the one in the > example. The former does not rely on unevaluated expressions, but > takes the conditioning values as a list, and it should work > regardless. However, if you do so I suggest you should install the > latest bugfix snapshot from bnlearn.com to avoid a few other bugs in > cpquery(..., method = "lw"). > > Cheers, > Marco > > -- > Marco Scutari, Ph.D. > Research Associate, Genetics Institute (UGI) > University College London (UCL), United Kingdom ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.