Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpm2tm can fail with strange error when using inappropriate input #6

Open
rdiaz02 opened this issue Jan 15, 2024 · 0 comments
Open

Comments

@rdiaz02
Copy link
Owner

rdiaz02 commented Jan 15, 2024

A user might try this

d1 <- data.frame(From = c("Root", "Root", rep(c("A", "B"), 3)),
                              To = c("A", "B", rep(c("C", "D", "E"), c(2, 2, 2))),
                              Relation = rep(c("Single", "AND", "OR", "XOR"), rep(2, 4)),
                              Lambdas = c(0.7, 0.8, rep(c(0.9, 0.4, 0.5), c(2, 2, 2))))

evamtools:::cpm2tm(d1)

which fails as

Error in as.environment(where) : using 'as.environment(NULL)' is defunct
> traceback()
2: exists("Relation", x$edges)
1: evamtools:::cpm2tm(ex_XOR_AND_OR)

So we probably want to:

  1. Check for the existance of the edges component and error early and with a clear message (like "No edges component in input. You are calling this function in an unintended way and/or with the wrong input").
  2. Use "Relation" %in% colnames(x$edges) instead of exists("Relation", x$edges): the second fails when x$edges does not exist.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant