-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Quietly load sf namespace when loading sf objects, for improved printing? #2212
Conversation
Cool trick -- thanks! |
reverts #2212 because of breaking revdeps
Reverting this now because of revdep errors, see #2275 |
I made this now conditional to |
Am I right in thinking it's just tidytransit that failed due to this? That'd be an easy enough fix, I'm happy to open a PR over there |
Probably not: you'd need a full revdep check with and without the PR, then compare. I use things like this for that purpose, and it only takes like 24 hours or so:
|
I knew you would! |
I decided (for now) to revert this change, before users get used to it, because I think it will make #2131 impossible, and that is something I want to explore first (and, on success, will have a larger impact). |
Initial tests suggest that I was wrong on Mar 20, that fixing #2131 does not interfere with this PR. |
Apologies for opening this as a PR, rather than as an issue, but I wanted to confirm this would actually work before I brought it up.
Right now, as mentioned in r-lib/pillar#552 , print methods for sf objects inheriting from tibbles is a bit broken if sf is not loaded in the session. This primarily impacts serialized objects, which might be read in via (for example)
readRDS()
without loading sf. The obvious fix for this is to load sf before loading the object, but it can be hard to identify this from the traceback that's returned.ggplot2 and, as of today, patchwork handle this by attaching a reference to their package namespace to their objects, so that the serialized object winds up loading the package and therefore the correct print methods -- for instance thomasp85/patchwork@f7fbab5 .
I'm wondering if it would be possible or desirable to do similar for sf objects, so that objects loaded via readRDS will print nicely even if sf is not loaded in the session. This PR includes an example of how that might be possible, if it is desirable.
Created on 2023-08-08 with reprex v2.0.2