jtextor / dagitty

Graphical analysis of structural causal models / graphical causal models.
GNU General Public License v2.0
252 stars 46 forks source link

Error `the condition has length > 1` #67

Open llrs opened 1 year ago

llrs commented 1 year ago

I made a mistake and tried to check adjustment from a plot instead of the of the DAG and there was an unexpected error:

library("dagitty")
library("ggdag")
#> 
#> Attaching package: 'ggdag'
#> The following object is masked from 'package:stats':
#> 
#>     filter
dag <- dagitty("dag{ 
  a -> b b -> c c -> d
 }")
plot <- ggdag(dag) + 
  theme_dag() + theme_dag_gray()
ggdag_adjustment_set(plot, outcome = "a")
#> Error in if (class(x) == "dagitty") {: the condition has length > 1

I think this could be just a simple case of replacing class(x) by is(x, "dagitty") in https://github.com/jtextor/dagitty/blob/ca4ec745ccfeaf8d283543c978e3691178748279/r/R/dagitty.r#L2625

Created on 2023-01-20 with reprex v2.0.2

malcolmbarrett commented 1 year ago

That code should use inherits(), either way