SachaEpskamp / qgraph

Developmental version of qgraph
GNU General Public License v2.0
68 stars 21 forks source link

Error in match.arg(op, choices = c(graph.RBGL, gRbase)) : argument "op" is missing, with no default #68

Closed duducrail closed 1 year ago

duducrail commented 1 year ago

Hi, When I try to plot a my BN I got the message on the title.

boot<-boot.strength(data, R=10000, algorithm = 'iamb') (this part is ok) qgraph(boot) (this line gives the error)

Using Mac, R 3.6.3 qgraph 1.9 gRbase 1.8.6.7

SachaEpskamp commented 1 year ago

Do you have a reproducible example? The code below works fine for me:

library('bnlearn')

df <- data.frame(
  a = rnorm(100),
  b = rnorm(100)
)
df$c <- df$a + df$b + rnorm(100)

boot<-boot.strength(df, R=10000, algorithm = 'iamb') 

library("qgraph")

qgraph(boot)
duducrail commented 1 year ago

Hi Sacha, thanks for the fast reply. I tried the exactly same code as you put above and got the same error. I think it's on my side. I did install/update some packages that I can't remember. And after doing this I got the error.

Maybe I'll try to reinstall R and qgraph all over again? Do you think it might work?

SachaEpskamp commented 1 year ago

What do you get when you run this?

packageVersion("bnlearn")
packageVersion("qgraph")
find("qgraph")
duducrail commented 1 year ago

Hi Sacha, I re-install before seeing your message. When I did that it solved the issue. Thank you.

duducrail commented 1 year ago

Hello again, this is what appears:

packageVersion("bnlearn") [1] ‘4.8.1’ packageVersion("qgraph") [1] ‘1.9.3’ find("qgraph") [1] "package:gRbase" "package:qgraph"

I wanted to use querygrain, and after installed gRain, gRbase, Rgraphviz, I got the same issue I had before I re-install all over again.

SachaEpskamp commented 1 year ago

Hi, sorry for the late reply on this. I see the problem now, the gRbase package also exports a function called qgraph, and so if you load the gRbase package after you load qgraph the qgraph(...) function will no longer work. You can explicitely call qgraph(...) from the qgraph package with qgraph::qgraph(...). So this should work:

library('bnlearn')

df <- data.frame(
  a = rnorm(100),
  b = rnorm(100)
)
df$c <- df$a + df$b + rnorm(100)

boot<-boot.strength(df, R=10000, algorithm = 'iamb') 

library("qgraph")

qgraph::qgraph(boot)