ordering doesn't work with more than one regression
chr1swallace opened this issue · 4 comments
chr1swallace commented
If I use order_vars with a list of regressions, only the first gets plotted. I think that's because in this line in dwplot, match() selects the first match
Line 132 in 2f5fa24
I think this is fixed by replacing the line with
df <- df[order(df$term),]
fsolt commented
Issue confirmed:
library(dotwhisker)
#> Loading required package: ggplot2
m1 <- lm(mpg ~ wt + cyl + disp + gear, data = mtcars)
m2 <- update(m1, . ~ . + hp) # add another predictor
m3 <- update(m2, . ~ . + am) # and another
dwplot(list(m1, m2, m3), order_vars = c("cyl", "disp", "gear", "wt", "am", "hp"))
Created on 2018-07-03 by the reprex
package (v0.2.0).
chr1swallace commented
Thanks for checking! With https://github.com/chr1swallace/dotwhisker seems fixed:
fsolt commented
And your fix works:
library(dotwhisker)
#> Loading required package: ggplot2
m1 <- lm(mpg ~ wt + cyl + disp + gear, data = mtcars)
m2 <- update(m1, . ~ . + hp) # add another predictor
m3 <- update(m2, . ~ . + am) # and another
dwplot(list(m1, m2, m3), order_vars = c("cyl", "disp", "gear", "wt", "am", "hp"))
Created on 2018-07-03 by the reprex
package (v0.2.0).
fsolt commented
Thanks, Chris! I appreciate your help with this!