Skip to content

Should global objects with external dependencies be functions? #361

Closed Answered by wlandau
djbirke asked this question in Help
Discussion options

You must be logged in to vote

Good question. Unless the object has brittle metadata (e.g. ropensci/drake#345) or system-dependent external pointers, I would recommend tracking the object as a global variable. That way, if you update the package where the object really lives, targets will invalidate the object and the appropriate downstream targets. If you wrap the object in a function, then targets will track the deparsed code to generate the object instead of the object itself. That means unless you call tar_option_set(imports = "ggplot2") (which seems cumbersome for your use case) updating the package will not invalidate the object.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@djbirke
Comment options

@wlandau
Comment options

@djbirke
Comment options

Answer selected by djbirke
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants