flr / FLR

General discussion, documentation and team work
0 stars 0 forks source link

EXPLORE the best options for package management in projects #3

Open iagomosqueira opened 2 years ago

iagomosqueira commented 2 years ago

Many R users are now using different packages and strategies to maintain package versions used on a particular analysis associated with the source code. I suggest exploring a few of them and provide some FLR-based tutorial and examples.

Idea from feedback on MSE course by @shfischer

iagomosqueira commented 2 years ago

Suggestion from @laurieKell : https://datacolada.org/95

shfischer commented 2 years ago

@laurieKell groundhog seems limited to CRAN R packages, so is of limited use for FLR.

I have started to look into the renv R package https://rstudio.github.io/renv/articles/renv.html

This seems to be a very useful tool for keeping track of package versions, in particular when used with a project in RStudio. The package sets up a local R package library and keeps a record of all R packages used within a project, including their dependencies. A benefit is that it can handle non-CRAN R packages, e.g. the FLR packages from GitHub. The package versions are stored in a renv.lock file with content such as:

(collapsed, click on details to expand)

{
  "R": {
    "Version": "4.1.0",
    "Repositories": [
      {
        "Name": "CRAN",
        "URL": "https://cran.rstudio.com"
      }
    ]
  },
  "Packages": {
    "FLCore": {
      "Package": "FLCore",
      "Version": "2.6.16.9002",
      "Source": "GitHub",
      "Repository": "flr",
      "RemoteType": "github",
      "RemoteHost": "api.github.com",
      "RemoteRepo": "FLCore",
      "RemoteUsername": "flr",
      "RemoteRef": "HEAD",
      "RemoteSha": "29597a52037839470b584acba643f37ae7b23ef2",
      "Hash": "b51c63466e90c337c721176ea92efa71"
    },
    "MASS": {
      "Package": "MASS",
      "Version": "7.3-54",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "0e59129db205112e3963904db67fd0dc"
    },
    "Matrix": {
      "Package": "Matrix",
      "Version": "1.3-3",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "df57c82e79600601287edfdcef92c2d6"
    },
    "R6": {
      "Package": "R6",
      "Version": "2.5.1",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "470851b6d5d0ac559e9d01bb352b4021"
    },
    "RColorBrewer": {
      "Package": "RColorBrewer",
      "Version": "1.1-2",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "e031418365a7f7a766181ab5a41a5716"
    },
    "cli": {
      "Package": "cli",
      "Version": "3.0.1",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "e3ae5d68dea0c55a12ea12a9fda02e61"
    },
    "colorspace": {
      "Package": "colorspace",
      "Version": "2.0-2",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "6baccb763ee83c0bd313460fdb8b8a84"
    },
    "crayon": {
      "Package": "crayon",
      "Version": "1.4.1",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "e75525c55c70e5f4f78c9960a4b402e9"
    },
    "digest": {
      "Package": "digest",
      "Version": "0.6.27",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "a0cbe758a531d054b537d16dff4d58a1"
    },
    "ellipsis": {
      "Package": "ellipsis",
      "Version": "0.3.2",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "bb0eec2fe32e88d9e2836c2f73ea2077"
    },
    "fansi": {
      "Package": "fansi",
      "Version": "0.5.0",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "d447b40982c576a72b779f0a3b3da227"
    },
    "farver": {
      "Package": "farver",
      "Version": "2.1.0",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "c98eb5133d9cb9e1622b8691487f11bb"
    },
    "ggplot2": {
      "Package": "ggplot2",
      "Version": "3.3.5",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "d7566c471c7b17e095dd023b9ef155ad"
    },
    "glue": {
      "Package": "glue",
      "Version": "1.4.2",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "6efd734b14c6471cfe443345f3e35e29"
    },
    "gtable": {
      "Package": "gtable",
      "Version": "0.3.0",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "ac5c6baf7822ce8732b343f14c072c4d"
    },
    "isoband": {
      "Package": "isoband",
      "Version": "0.2.5",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "7ab57a6de7f48a8dc84910d1eca42883"
    },
    "iterators": {
      "Package": "iterators",
      "Version": "1.0.13",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "64778782a89480e9a644f69aad9a2877"
    },
    "labeling": {
      "Package": "labeling",
      "Version": "0.4.2",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "3d5108641f47470611a32d0bdf357a72"
    },
    "lattice": {
      "Package": "lattice",
      "Version": "0.20-44",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "f36bf1a849d9106dc2af72e501f9de41"
    },
    "lifecycle": {
      "Package": "lifecycle",
      "Version": "1.0.0",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "3471fb65971f1a7b2d4ae7848cf2db8d"
    },
    "magrittr": {
      "Package": "magrittr",
      "Version": "2.0.1",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "41287f1ac7d28a92f0a286ed507928d3"
    },
    "mgcv": {
      "Package": "mgcv",
      "Version": "1.8-35",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "89fd8b2ad4a6cb4979b78cf2a77ab503"
    },
    "munsell": {
      "Package": "munsell",
      "Version": "0.5.0",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "6dfe8bf774944bd5595785e3229d8771"
    },
    "nlme": {
      "Package": "nlme",
      "Version": "3.1-152",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "35de1ce639f20b5e10f7f46260730c65"
    },
    "pillar": {
      "Package": "pillar",
      "Version": "1.6.2",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "43f228eb4b49093d1c8a5c93cae9efe9"
    },
    "pkgconfig": {
      "Package": "pkgconfig",
      "Version": "2.0.3",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "01f28d4278f15c76cddbea05899c5d6f"
    },
    "renv": {
      "Package": "renv",
      "Version": "0.14.0",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "30e5eba91b67f7f4d75d31de14bbfbdc"
    },
    "rlang": {
      "Package": "rlang",
      "Version": "0.4.11",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "515f341d3affe0de9e4a7f762efb0456"
    },
    "scales": {
      "Package": "scales",
      "Version": "1.1.1",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "6f76f71042411426ec8df6c54f34e6dd"
    },
    "tibble": {
      "Package": "tibble",
      "Version": "3.1.4",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "5e8ad5621e5c94b24ec07b88eee13df8"
    },
    "utf8": {
      "Package": "utf8",
      "Version": "1.2.2",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "c9c462b759a5cc844ae25b5942654d13"
    },
    "vctrs": {
      "Package": "vctrs",
      "Version": "0.3.8",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "ecf749a1b39ea72bd9b51b76292261f1"
    },
    "viridisLite": {
      "Package": "viridisLite",
      "Version": "0.4.0",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "55e157e2aa88161bdb0754218470d204"
    },
    "withr": {
      "Package": "withr",
      "Version": "2.4.2",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "ad03909b44677f930fa156d47d7a3aeb"
    }
  }
}

The exact package versions can then be restored on any system with renv::restore(), and even loads the FLR packages from GitHub through their commit hash.

iagomosqueira commented 2 years ago

Can this be set to only store local copies of some packages and rely on CRAN or FLR repository for others? Might be useful to only bother about those likely to change and not a full load of, for example ggplot2 dependencies.

What do you think about writing a short tutorial using FLR packages?

shfischer commented 2 years ago

I will look into this and try to set up a simple tutorial.

shfischer commented 2 years ago

A bit delayed but here is a small example using renv: https://github.com/shfischer/FLR_renv_example#readme

iagomosqueira commented 2 years ago

Very much delayed, but we now have flr in r-universe,

https://flr.r-universe.dev/ui#packages

which gives access to a repository with the latest versions com,piled for windows and osx.

install.packages("mse", repos= 'https://flr.r-universe.dev')

Maybe we could take a look at this

https://ropensci.org/blog/2022/01/06/runiverse-renv/

and come up with a good strategy for using renv, r-universe and TAF.