fsolt / dotwhisker

Dot-and-Whisker Plots of Regression Results
https://fsolt.org/dotwhisker/
Other
60 stars 10 forks source link

Multi-model presentation #55

Closed sammo3182 closed 8 years ago

sammo3182 commented 8 years ago

The dodging function doesn't work. Estimates overlap to each other. Suspect codes are in line 170 in dwplot.R (e52272b72574bb19dea3a78c78fa45867d175840), where do.call seems not calling for the segment_args

sammo3182 commented 8 years ago

Some new finding of the error: it is perhaps not the problem of ggplot2 but dplyr. I ran the codes in the vignette in a PC without updating dplyr to 0.5.0, and the plot showed well.

fsolt commented 8 years ago

That's good to know!

sammo3182 commented 8 years ago

Fred @fsolt, I believe the error has been fixed by deleting the arrange in dwplot.R (still saved as a comment in line 240). I don't figure out why you set the arrange(term) there. If this is a necessary step, we may need to figure a way to record the original term order then. Otherwise, all the errors in the existing version have been fixed, and we may ready to release a new version to CRAN. The package has passed the R CMD check.

fsolt commented 8 years ago

Let's go with that for now, and we can see if it crops up as a bug. Thanks, Hu, for being on this.

fsolt commented 8 years ago

Aha! It was there to deal with multiple models that don't include all the same variables. I'll see if I can't get it fixed now.

sammo3182 commented 8 years ago

Yes. Most problems were caused by the add_NAs according to my detection. Within the function, we used group_by and arrange, while it seems the latter will ignore the former according to Hadley (https://blog.rstudio.org/2016/06/27/dplyr-0-5-0/). I manually created a term-order vector (order_vars) and arrange the rows through joint function for now.

fsolt commented 8 years ago

I'm trying it out on meritocracy paper now, and it's not working: at first glance, it looks like the NA rows are being ignored: problem

fsolt commented 8 years ago

okay, so it looks like the issue is add_NAs is now disregarding order_var as specified in the dwplot arguments

fsolt commented 8 years ago

All right: this all goes back to #54, the dplyr update edits. The big change with dplyr 0.5.0 is that arrange() now ignores grouping (see https://github.com/hadley/dplyr/blob/master/NEWS.md), so the line df <- dft %>% group_by(model) %>% arrange(term) %>% ungroup() wasn't producing the desired result. That, plus perhaps the switch to full_join, motivated converting term to character rather than factor in df, m, and t. But, for once, the factor type is actually useful because we're using it to record the order specified in the order_var argument. So the solution instead is to (1) bring back the factors (!), and (2) move the arrange(term) back up to m (which is each model separately and so doesn't need to be grouped by model).