ngreifer / cobalt

Covariate Balance Tables and Plots - An R package for assessing covariate balance
https://ngreifer.github.io/cobalt/
72 stars 11 forks source link

love.plot: Error in scale_override_call(call) #83

Open rafaelglezm opened 7 months ago

rafaelglezm commented 7 months ago

I'm trying to produce a loveplot of a matchit object, but I get the following error "Error in scale_override_call(call) : could not find function "scale_override_call"

I'm using MacOS, R 4.3.2 and the last Cobalt GitHub version (cobalt_4.5.4), and ggplot2 3.5.0

The code is the following:

matching_obj <- matchit(y ~ a + b + c + d, data = dataset, method = "nearest", ratio = 2, caliper = 0.1) love.plot(matching_obj, binary = "std", sample.names = c("Unmatched", "Matched"), thresholds = c(m = .1), title = NULL)

Thanks in advance

ngreifer commented 7 months ago

Hi Rafael,

Unfortunately, I am not able to replicate this issue using these versions of the package. The updated version of cobalt is on CRAN, so you should be able to install it from there.

To diagnose this issue, can you give me a minimally reproducible data example (e.g., using lalonde), and when you get the error, please run traceback() and include the output in your reply.

rafaelglezm commented 7 months ago

Hi Noah Thank you very much for your quick response and help. I have restarted R, re-installed Cobalt from CRAN (Version 4.5.4, Build Date: 2024-02-26), and now it works perfectly Best regards, Rafael

himawork commented 7 months ago

So did I

library(cobalt) data("lalonde", package = "cobalt")

Propensity score weighting

w.out1 <- WeightIt::weightit( treat ~ age + educ + race + married + nodegree + re74 + re75, data = lalonde )

love.plot(w.out1, thresholds = c(m = .1), var.order = "unadjusted")

Error in scale_override_call(call) :

could not find function "scale_override_call"

re-install cobalt didn't solve this error and I didn't find function "scale_override_call" in any source file of cobalt package.

ngreifer commented 7 months ago

@himawork it's code that exists in ggplot2, so my only recommendation would be to reinstall that and try again. Unfortunately I cannot reproduce the error on my machine.

jdeu1023 commented 6 months ago

I also had this issue. I uninstalled ggplot2 and cobalt then reinstalled them, and that fixed it.