Skip to content

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

@rdiaz02

Description

@rdiaz02

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions