Call specific package versions in markdown

Hi all,

Fairly new to R here, so hopefully I'll be able to keep up with any replies! I have an inherited rmarkdown script that simply would not run on my computer until I learned that the script had been written around an outdated version of the Scorecard package.

Given that our organization tends to share scripts across many people, I am hoping to find a way to be able to control for this in an Rmarkdown.

Specifically, when loading packages at the beginning of the script, is it possible to specify version numbers of the package? Would love to hear from anyone who might have insights into this!

Hi, this is a tough problem because it goes beyond just specific package versions in scripts. There is versions, which can partially address the problem (at least going back five years), but there's no guarantee that any particular earlier version of a package is going satisfy dependency requirements of a current or even recent version of another package.

To minimize this type of problem and related gotchas, what I do in my one-person shop is:

  1. Keep the OS at its current version (and in my case XCODE and its command line tools)
  2. Keep R at its current version
  3. Run update.packages() at least daily
  4. Put Rmd files in RStudio .Rproj directories under git control

It's unreasonable to expect to have an organization in which all users follow this discipline. If there's no IT or they are an "everything is already perfect, if only we could eliminate users" bent, I'd take a look at some of commercial products. (No, I don't get a commission or freebies, sniff.) Exposing the functionality through a Shiny Server allows a single point of control for versioning and other maintenance issues without any burden on users.

That's very helpful, thank you very much for the reply! I will definitely have a look at the versions package, as that may be a good way to at least provide some level of stability to the process while we try to look for a long-term solution.

Obviously, rewriting these when it becomes necessary is ideal. Unfortunately, we also have highly variable levels of competence with R. If a very proficient user writes a markdown, and it is later passed to a fairly new user (i.e. this exact situation), interpreting the flow of the script and being able to replicate the step can be a fairly challenging situation.

That said, I think this is a great step in our attempts to keep everything stable. Thanks again!

This lists many of the available options for dealing with different package versions:

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.