cobalt icon indicating copy to clipboard operation
cobalt copied to clipboard

love.plot: Error in scale_override_call(call)

Open rafaelglezm opened this issue 1 year ago • 5 comments

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

rafaelglezm avatar Feb 29 '24 15:02 rafaelglezm

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.

ngreifer avatar Feb 29 '24 20:02 ngreifer

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

rafaelglezm avatar Mar 01 '24 06:03 rafaelglezm

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.

himawork avatar Mar 04 '24 02:03 himawork

@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.

ngreifer avatar Mar 04 '24 04:03 ngreifer

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

jdeu1023 avatar Mar 16 '24 01:03 jdeu1023