joshuaulrich / xts

Extensible time series class that provides uniform handling of many R time series classes by extending zoo.
http://joshuaulrich.github.io/xts/
GNU General Public License v2.0
219 stars 70 forks source link

Noisy message when loaded by quantmod #393

Closed dmurdoch closed 1 year ago

dmurdoch commented 1 year ago

You are now printing a big ugly message in your .onAttach function about the conflict between stats::lag and dplyr::lag. That's a real issue, and it's a problem if I was using dplyr, but I'm not, I just have it installed. I'm not even attaching xts, I'm just importing quantmod, and quantmod attaches it. Don't you think that's excessive?

dmurdoch commented 1 year ago

A suggestion: if dplyr is not already attached, just set a hook to give the message out if it is attached, e.g.

setHook(packageEvent("dplyr", "attach"), function(...) uglyMessage())
joshuaulrich commented 1 year ago

Hi Duncan, thanks for the report!

Don't you think that's excessive?

Yes, I agree it's excessive to print the warning when dplyr's installed but not being used. But I didn't have a better idea how to warn the user that attaching dplyr after attaching xts would be a problem. I really like your suggestion to use setHook() and I'll add that to the next release.

I'm not a huge fan of noisy package startup messages, but dplyr::lag() masking causes enough subtle issues that I thought it was worth being noisy and warning end users. Especially because the dplyr team could fix this but has shown no interest in doing so since they introduced this anti-social behavior.

I'd appreciate any other thoughts you have about how to only raise this warning when it's appropriate.

joshuaulrich commented 1 year ago

@dmurdoch I've implemented your suggestion and added it to the main branch. Please let me know if there's anything else we can do to make sure the warning is only shown at appropriate times.

Thanks again for the report and fix!