Some surprises are good
But this is production, not showbiz.
Think of your data science workbench as a kitchen:
- A repository is the grocery store, a central place where everyone gets their packages.
- A library is the pantry, where you keep your own private set of packages.
- A Package is the food!
👿 Sometimes things go wrong
insert function from package
} worked before…”renv
The renv package helps you create reproducible environments for your R projects. Use renv to make your R projects more:
Isolated: Installing a new or updated package for one project won’t break your other projects, and vice versa. That’s because renv gives each project its own private package library.
Portable: Easily transport your projects from one computer to another, even across different platforms. renv makes it easy to install the packages your project depends on.
Reproducible: renv records the exact package versions you depend on, and ensures those exact versions are the ones that get installed wherever you go.
renv
renv.lock
renv
is designed to keep track of your PROJECT’S PACKAGE DEPENDENCIESrenv.lock
file using renv::snapshot()
{
"R": {
"Version": "4.3.1",
"Repositories": [
{
"Name": "RSPM",
"URL": "https://packagemanager.posit.co/cran/latest"
}
]
},
"Packages": {
"BH": {
"Package": "BH",
"Version": "1.81.0-1",
"Source": "Repository",
"Repository": "RSPM",
"Hash": "68122010f01c4dcfbe58ce7112f2433d"
},
"DBI": {
"Package": "DBI",
"Version": "1.1.3",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"methods"
],
"Hash": "b2866e62bab9378c3cc9476a1954226b"
},
"DT": {
"Package": "DT",
"Version": "0.28",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"crosstalk",
"htmltools",
"htmlwidgets",
"jquerylib",
"jsonlite",
"magrittr",
"promises"
],
"Hash": "ab745834dfae7eaf71dd0b90f3b66759"
}
renv.lock
renv
is designed to keep track of your PROJECT’S PACKAGE DEPENDENCIESrenv.lock
file using renv::snapshot()
renv::restore()
Follow along with me - Getting started with renv
Ensure your data products behave as expected and there are no surprises
📣 Push-button is good for rapid prototyping. Beyond that, you really should be using git-backed or programmatic deployment via CI/CD pipeline to keep your code in sync with your deployment.
Connect will deploy directly from your git repository
Ref:
Deploy production and test branches
Automatically update production with a git merge
Stakeholders keep the same stable URL throughout
rsconnect-python
) or R (connectapi
) packagehttps://posit-conf-2024.github.io/ds-workflows-r/resources.html
Please go to pos.it/conf-workshop-survey. Your feedback is crucial! Data from the survey informs curriculum and format decisions for future conf workshops, and we really appreciate you taking the time to provide it.
Click to go back to Data Science Workflows with Posit Tools - R Focus website ↩︎