Skip to content

Commit

Permalink
deserialize -> unserialize throughout
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemahoney218 committed Nov 27, 2023
1 parent 126de47 commit 6b500bb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion posts/2023-11-27-objects-loading-namespaces/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ run_isolated(

Anyway, back to the point. Complicated objects print ugly, and don't have any of their other methods available, when you unserialize them in a new session.

The reason for this is pretty straightforward: the print (and other) methods are inside the namespace of the package that created the objects,^[I mean, mostly. Some packages like [broom](https://broom.tidymodels.org) provide a bunch of methods for objects that don't come from that package. But those packages aren't automatically loaded on deserialization either (and can you imagine how chaotic a world that would be!), so the basic point stands.] if that namespace isn't loaded then R can't find the methods when they're needed, and deserializing the object doesn't automatically load the relevant namespace. So the reason that `boston_canopy` printed nicely in our current session is that spatialsample sneakily loaded sf in the background when we called the `boston_canopy` object:^[More on the trick [in this old blog post](https://www.mm218.dev/posts/2022-12-01-sf-in-packages/).]
The reason for this is pretty straightforward: the print (and other) methods are inside the namespace of the package that created the objects,^[I mean, mostly. Some packages like [broom](https://broom.tidymodels.org) provide a bunch of methods for objects that don't come from that package. But those packages aren't automatically loaded on unserialization either (and can you imagine how chaotic a world that would be!), so the basic point stands.] if that namespace isn't loaded then R can't find the methods when they're needed, and unserializing the object doesn't automatically load the relevant namespace. So the reason that `boston_canopy` printed nicely in our current session is that spatialsample sneakily loaded sf in the background when we called the `boston_canopy` object:^[More on the trick [in this old blog post](https://www.mm218.dev/posts/2022-12-01-sf-in-packages/).]

```{r}
is_sf_loaded <- function() {
Expand Down

0 comments on commit 6b500bb

Please sign in to comment.