0

I'm new to r programming language. I would like know how packages are specified with their specific versions in a requirements file, for example for python you can have a requirements.txt file specifying a specifying django as a package with the version 1.11, this can specified as django==1.11. I have looked on the web for something similar regarding r, but all I managed to find is the file holding the packages without their versions specified, link to the file https://github.com/binder-examples/r/blob/master/install.R. Is this how the requirements file is defined in r? I would also like to know if it is possible to install multiple packages at once in r for specific versions, after looking through the web I was able to find this https://stackoverflow.com/a/29041447/8513875 however it show how to just install multiple packages but doesn't include how to install specific versions of the packages. An extra note I will be installing the packages through the terminal. Any help will be much appreciated thank you.

oma0256
  • 103
  • 4
  • 11
  • 2
    If you need this (why?), you should build a package. You can easily specify package dependencies including their versions. Alternatively, you might be interested in [packrat](https://rstudio.github.io/packrat/walkthrough.html). However, in our usually everyday work, most of us don't care much about package versions. We tend to use newer versions and trust package maintainers not to do too many breaking changes. – Roland Aug 24 '20 at 07:41
  • @Roland ohhh.. I see so reason being is usually in python you can find that the latest version of a package is not compatible with for instance an old version python or some of the functions you used in your code have functions that have been removed from the latest version of the package. To add up I will be using the terminal to perform these installations. – oma0256 Aug 24 '20 at 07:54
  • @Roland is this something that wouldn't happen in `r`? – oma0256 Aug 24 '20 at 08:08
  • It does happen but is much rarer than in python. – Roland Aug 24 '20 at 08:23
  • @Roland in that case is it possible to have the version for each package specified in the `install.R` file? – oma0256 Aug 24 '20 at 09:05
  • 1
    The issue is that you need a repository that hosts the package version. CRAN only offers the most recent versions. A possible option would be to use the [snap shots on MRAN](https://mran.microsoft.com/timemachine) but that is not as simple as specifying which version should be installed. Due to the limited CRAN resources, we don't have good support for version-specific installation in R (which is not trivial because of potentially huge dependency trees). – Roland Aug 24 '20 at 09:17
  • @Roland thank you understood make sense. – oma0256 Aug 24 '20 at 11:18

0 Answers0