diff --git a/.gitignore b/.gitignore index 47753f6..dfb025d 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,7 @@ src/**/*.md _book* !_bookdown.yml src/private_code.R +*.gpkg* +*.qgs +*.bak +*.qgz diff --git a/src/generate_habitatquarries/.Rprofile b/src/generate_habitatquarries/.Rprofile new file mode 100644 index 0000000..81b960f --- /dev/null +++ b/src/generate_habitatquarries/.Rprofile @@ -0,0 +1 @@ +source("renv/activate.R") diff --git a/src/generate_habitatquarries/10_generate_habitatquarries.Rmd b/src/generate_habitatquarries/10_generate_habitatquarries.Rmd new file mode 100644 index 0000000..10c9137 --- /dev/null +++ b/src/generate_habitatquarries/10_generate_habitatquarries.Rmd @@ -0,0 +1,345 @@ +# Making the data source + +We will create a 'raw' data source `habitatquarries` by cleaning a precursor dataset. + +```{r} +local_root <- find_root(has_file("generate_habitatquarries.Rproj")) +datapath <- file.path(local_root, "data") +if (!dir.exists(datapath)) dir.create(datapath) +finalpath <- find_root_file("n2khab_data/10_raw/habitatquarries", + criterion = has_dir("n2khab_data")) +if (!dir.exists(finalpath)) dir.create(finalpath) +``` + + +## Load draft dataset + +_This code is no longer executed because of the manual steps undertaken afterwards._ +_Go directly to [manual updates](#manual-updates)._ + +```{r eval=FALSE} +drive_auth(email = TRUE) +drive_ls(as_id("1tJLjAlVbcNHcP4bgp7zRLS9e0KB9vyMs")) %>% + {map2(.$name, .$id, function(name, id) { + drive_download(as_id(id), + path = file.path(tempdir(), name), + overwrite = TRUE) + })} %>% + invisible() +``` + + +```{r paged.print = FALSE, eval=FALSE} +habitatquarries <- read_sf(file.path(tempdir(), "8310_v2018_RAPHAB2019.shp"), + crs = 31370) +``` + +```{r paged.print = FALSE, eval=FALSE} +habitatquarries +``` + +## First standardization steps + +_This code is no longer executed because of the manual steps undertaken afterwards._ +_Go directly to [manual updates](#manual-updates)._ + +From common values of variables `id_old1` and `id_old2` in the below standardized dataset, we will derive a `unit_id` variable that represents somehow interconnected systems: + +```{r paged.print = FALSE, eval=FALSE} +(habitatquarries <- + habitatquarries %>% + select(id_old1 = Id, + id_old2 = nr, + name = Naam, + type = HT8310, + source = Bron)) +``` + +Writing a derived dataset that contains the auto-generated `unit_id`: + +```{r eval=FALSE} +habitatquarries %>% + st_drop_geometry %>% + count(id_old1, id_old2) %>% + filter(n > 1, id_old1 > 0 | id_old2 > 0) %>% + mutate(unit_id = 1:nrow(.)) %>% + select(-n) %>% + right_join(habitatquarries, by = c("id_old1", "id_old2")) %>% + select(-contains("old")) %>% + st_write(file.path(datapath, + "habitatquarries1.gpkg"), + delete_dsn = TRUE) +``` + +## Manual updates + +At this stage, `habitatquarries1.gpkg` has been copied to `habitatquarries2.gpkg` which was subsequently edited in **QGIS** 3.14: + +- updated a truncated value for `source`; +- capitalized a lowercase name in `source`; +- added a few extra `unit_id` values for adjacent polygons and interconnected quarries; +- deleted 2 rows without geometry; +- updated the value of `type` for one polygon; +- updated the value of `name` for many polygons; +- updated the value of `source` for many polygons. + +```{r eval=FALSE} +# Saving/updating the manually crafted habitatquarries2.gpkg in Google Drive: +drive_update(media = file.path(datapath, "habitatquarries2.gpkg"), + file = as_id("1aM3hZqEp3ax66PCrhuyjwBZKd3EcALUS")) +``` + +After that, further standardization has been done on the result, in an attempt to create a first version of the final file. +This refers to the state of paragraph \@ref(standardization) at commit 4f41a46 (2020-07-02 08:58:29 +0200). + +Then, the file has been reworked manually again, regarding both geometry and non-spatial attributes. +This mainly had to do with the applied definition of a 'unit'; see the Zenodo metadata for more information. +The result was the shapefile `habitatquarries_v2_20200925.shp`, which will now be handled further by the R code. + +## Final standardization and writing the resulting data source {#standardization} + +Reading `habitatquarries_v2_20200925.shp` and turning it into a standardized data source: + +```{r} +drive_auth(email = TRUE) +drive_ls(as_id("14MGdxHtxe8VGaCu70Y8Pmc0jusZgpym9")) %>% + filter(str_detect(name, "habitatquarries_v2_20200925")) %>% + {map2(.$name, .$id, function(name, id) { + drive_download(as_id(id), + path = file.path(tempdir(), name), + overwrite = TRUE) + })} %>% + invisible() +``` + + +```{r paged.print = FALSE} +read_sf(file.path(tempdir(), + "habitatquarries_v2_20200925.shp")) %>% + select(polygon_id, + unit_id, + name, + habitattype = habitattyp, + extra_reference = extra_refe) %>% + arrange(unit_id >= 100, name, polygon_id) %>% + mutate(polygon_id = as.integer(polygon_id), + unit_id = as.integer(unit_id)) %>% + st_write(file.path(finalpath, "habitatquarries.gpkg"), + delete_dsn = TRUE) +``` + +# Adding the bibliography + +The literature references have been saved as a BibTeX bibliography file `habitatquarries.bib`, making it usable by most reference management software and R Markdown. + +We will include this information as a table inside the GeoPackage, in order to make the latter self-contained, but we'll do that in a way that it can be read out to a BibTeX file. + +## Creating a dataframe from the BibTeX bibliography file + +```{r warning=FALSE} +refs <- bib2df(file.path(datapath, "habitatquarries.bib")) +``` + + +```{r} +refs2 <- + refs %>% + map_lgl(function(col) any(!is.na(col))) %>% + refs[,.] %>% + `colnames<-`(tolower(colnames(.))) %>% + mutate(author = map_chr(author, + function(x) paste(x, collapse = " and "))) +``` + + +```{r} +glimpse(refs2) +``` + +Suggestion for making a function to read back as BibTeX bibliography: + +```{r eval=FALSE} +refs2 %>% + mutate(author = str_split(author, " and ")) %>% + `colnames<-`(toupper(colnames(.))) %>% + df2bib +``` + +## Adding the dataframe to the GeoPackage + +```{r} +refs2 %>% + st_write(file.path(finalpath, "habitatquarries.gpkg"), + layer = "extra_references", + delete_layer = TRUE) +``` + + + +# Checks on the data source + +```{r} +filepath <- file.path(finalpath, "habitatquarries.gpkg") +``` + + +Checksums: + +```{r} +file(filepath) %>% + openssl::md5() %>% + str_c(collapse = '') %>% + `names<-`("md5sum") +file(filepath) %>% + openssl::sha256() %>% + str_c(collapse = '') %>% + `names<-`("sha256sum") +``` + + +Available layers: + +```{r paged.print = FALSE} +st_layers(filepath) +``` + +## Geospatial layer + +Reading from file: + +```{r paged.print = FALSE} +habitatquarries_test <- + read_sf(filepath, + layer = "habitatquarries") +``` + +Writing attributes to text file for version control: + +```{r} +habitatquarries_test %>% + st_drop_geometry %>% + write_tsv("data/habitatquarries.tsv") +``` + +Overview of contents: + +```{r paged.print = FALSE} +habitatquarries_test %>% + print(n = Inf) +``` + +All attributes: + +```{r} +habitatquarries_test %>% + st_drop_geometry +``` +Number of unique combinations of `unit_id` and `name`: + +```{r} +habitatquarries_test %>% + st_drop_geometry %>% + count(unit_id, name) %>% + kable +``` + +Number of unique values of `habitattype`: + +```{r} +habitatquarries_test %>% + st_drop_geometry %>% + count(habitattype) +``` +When `habitattype = "gh"` we know that no habitat is present. +When unknown (outside of Flanders), it is set as `NA`. + +Occurrence of different references: + +```{r paged.print = FALSE} +habitatquarries_test %>% + st_drop_geometry %>% + count(extra_reference) +``` + +```{r warning=FALSE} +provinces_path <- find_root_file("n2khab_data/10_raw/provinces", + criterion = has_dir("n2khab_data")) +provinces <- + read_sf(provinces_path, crs = 31370) +bbox1 <- st_bbox(habitatquarries_test) +``` + +Overview map: + +```{r} +ggplot() + + geom_sf(data = provinces, fill = "white", colour = "grey70") + + geom_sf(data = habitatquarries_test, + colour = NA, + aes(fill = factor(unit_id))) + + coord_sf(datum = st_crs(31370), + xlim = bbox1$xlim + c(-2e3, 2e3), + ylim = bbox1$ylim + c(-2e3, 2e3)) + + theme_bw() + + theme(legend.position = "none") +``` + +Zoomed in on the eastern part: + +```{r} +zoom <- coord_sf(datum = st_crs(31370), + xlim = c(234e3, 244e3), + ylim = c(163e3, 169.2e3)) +ggplot() + + geom_sf(data = provinces, fill = "white", colour = "grey70") + + geom_sf(data = habitatquarries_test, + colour = NA, + aes(fill = factor(unit_id))) + + zoom + + geom_sf_text(data = habitatquarries_test, + aes(label = unit_id), + size = 3) + + theme_bw() + + theme(legend.position = "none", + axis.title = element_blank()) +``` + +With the values shown of `habitattype`: + +```{r} +ggplot() + + geom_sf(data = provinces, fill = "white", colour = "grey70") + + geom_sf(data = habitatquarries_test, + colour = NA, + aes(fill = `habitattype`)) + + zoom + + theme_bw() + + theme(legend.position = "bottom") +``` + + +## Table with extra references + +Reading from file: + +```{r paged.print = FALSE} +extra_references <- + read_sf(filepath, + layer = "extra_references") +``` + +Overview of structure: + +```{r paged.print = FALSE} +extra_references %>% + glimpse() +``` + +Closer inspection: + +```{r} +extra_references +``` + +The above table can be converted back into a BibTeX bibliography file, using code as shown above. + diff --git a/src/generate_habitatquarries/99_sessioninfo.Rmd b/src/generate_habitatquarries/99_sessioninfo.Rmd new file mode 100644 index 0000000..c06f9d8 --- /dev/null +++ b/src/generate_habitatquarries/99_sessioninfo.Rmd @@ -0,0 +1,19 @@ +# Used environment + +```{r session-info, results = "asis", echo=FALSE} +si <- devtools::session_info() +p <- si$platform %>% + do.call(what = "c") +if ("sf" %in% si$packages$package) p <- c(p, sf_extSoftVersion()) +sprintf("- **%s**:\n %s\n", names(p), p) %>% + cat() +``` + +```{r results = "asis", echo=FALSE} +si$packages %>% + as_tibble %>% + select(package, loadedversion, date, source) %>% +pander::pandoc.table(caption = "(\\#tab:sessioninfo)Loaded R packages", + split.table = Inf) +``` + diff --git a/src/generate_habitatquarries/_bookdown.yml b/src/generate_habitatquarries/_bookdown.yml new file mode 100644 index 0000000..c137ede --- /dev/null +++ b/src/generate_habitatquarries/_bookdown.yml @@ -0,0 +1,4 @@ +book_filename: "generating_habitatquarries.Rmd" +new_session: FALSE +rmd_files: # specifies the order of Rmd files; NOT needed when you use index.Rmd and an alphabetical order for other Rmd files + # - index.Rmd diff --git a/src/generate_habitatquarries/data/habitatquarries.bib b/src/generate_habitatquarries/data/habitatquarries.bib new file mode 100644 index 0000000..50eb373 --- /dev/null +++ b/src/generate_habitatquarries/data/habitatquarries.bib @@ -0,0 +1,109 @@ +% This file was created with JabRef 2.10. +% Encoding: UTF8 + + +@Book{de_haan_inventarisatie_2018, + Title = {Inventarisatie en waardering van de mergelgroeve ‘{Grote} {Berg}’ te {Zussen}}, + Author = {De Haan, A. and Lahaye, M.}, + Publisher = {Agentschap Onroerend Erfgoed}, + Year = {2018}, + + Address = {Brussels}, + Series = {Onderzoeksrapport van het {Agentschap} {Onroerend} {Erfgoed}}, + + Url = {https://www.vlaanderen.be/publicaties/inventarisatie-en-waardering-van-de-mergelgroeve-grote-berg-te-zussen-onderzoeksrapport} +} + +@InCollection{dusar_mergelgrotten_2007, + Title = {De {Mergelgrotten} van {Hinnisdael} te {Vechmaal}, geologisch erfgoed in de schaduw}, + Author = {Dusar, M and Dreesen, R. and Lagrou, D.}, + Booktitle = {Likona jaarboek}, + Publisher = {Likona (Limburgse Koepel voor Natuurstudie)}, + Year = {2007}, + + Address = {Genk}, + Pages = {6-13}, + Volume = {2006} +} + +@Book{jennekens_pitjesberg_2012, + Title = {De {Pitjesberg}}, + Author = {Jennekens, Peter and Hageman, John}, + Publisher = {Riemster Monumenten en landschappen}, + Year = {2012}, + + Address = {Riemst} +} + +@InCollection{lahaye_groeve_2018, + Title = {Groeve het {Avergat}. {Visie} van de gemeente {Riemst}}, + Author = {Lahaye, Mike}, + Year = {2018}, + + Address = {Riemst}, + Pages = {12}, + + Url = {https://www.riemst.be/sites/default/files/public/_development/5-Wonen/5_7_4_Groeven/Publicaties/visie%20avergat.pdf} +} + +@Book{verhoeven_studieopdracht_2008, + Title = {Studieopdracht naar een archeologische evaluatie van het plateau van {Caestert} ({Riemst}, {Provincie} {Limburg})}, + Author = {Verhoeven, M.P.F.}, + Publisher = {RAAP Archeologisch Adviesbureau}, + Year = {2008}, + + Address = {Weert}, + Number = {1769}, + Series = {{RAAP}-rapport}, + + Url = {https://oar.onroerenderfgoed.be/publicaties/STUA/3/STUA003-001.pdf} +} + +@Book{walschot_over_2010, + Title = {Over groeve {De} {Keel}. {De} boven- en ondergrondse geschiedenis van een kalksteengroeve en haar omgeving}, + Author = {Walschot, Luck}, + Publisher = {Stichting Ondergrondse Werken}, + Year = {2010}, + + ISBN = {97890090257174} +} + + +@misc{wikipedia_muizenberg_2019, + title = {Muizenberg ({Limburg})}, + copyright = {Creative Commons Attribution-ShareAlike License}, + url = {https://nl.wikipedia.org/w/index.php?title=Muizenberg_(Limburg)&oldid=53081088}, + abstract = {De Muizenberg is een ondergrondse mergelgroeve gelegen in het zuidelijke deel van de Cannerberg, grotendeels behorende tot de gemeente Riemst (België), op de grens van Nederland en België ten westen van grenspaal 70. Het gangenstelsel had vroeger een eigen ingang aan de weg Kanne-Vroenhoven, eveneens Muizenberg geheten, en ten zuiden van de veldweg genaamd chemin de la Xhavée. De deels ingestorte groeve stond in verbinding met de groeve Boschberg, thans ook Kasteelgroeve of Cannerberggroeve genoemd.}, + language = {nl}, + urldate = {2020-06-30}, + author = {{Wikipedia}}, + month = {jan}, + year = {2019}, + note = {Page Version ID: 53081088} +} + +@misc{limburgs_landschap_natuurgebied_2020, + title = {Natuurgebied {De} {Coolen}}, + url = {https://limburgs-landschap.be/de-coolen/}, + abstract = {De Coolen is een hellingbosje met een middelgrote mergelgroeve. Omwille van de veiligheid en de bescherming van de vleermuizen is de grot niet toegankelijk.}, + language = {nl}, + urldate = {2020-06-30}, + author = {{Limburgs Landschap}}, + month = {apr}, + year = {2020}, + note = {Library Catalog: limburgs-landschap.be} +} + +@article{silvertant_ontstaansgeschiedenis_2003, + title = {De Ontstaansgeschiedenis van de Gangenstelsels Te {{Klein}}-{{Ternaaien}} ({{België}})}, + author = {Silvertant, J.}, + editor = {{Natuurhistorisch Genootschap in Limburg Maastricht NL}}, + year = {2003}, + volume = {92}, + pages = {334--340}, + issn = {0028-1107}, + journal = {Natuurhistorisch Maandblad}, + keywords = {belgië,belgium,geschiedenis,history,marl soils,mergelgronden,mijnbouw,mining,onderzoek,quarries,research,steengroeven}, + number = {12} +} + diff --git a/src/generate_habitatquarries/data/habitatquarries.tsv b/src/generate_habitatquarries/data/habitatquarries.tsv new file mode 100644 index 0000000..dfcc673 --- /dev/null +++ b/src/generate_habitatquarries/data/habitatquarries.tsv @@ -0,0 +1,46 @@ +polygon_id unit_id name habitattype extra_reference +4 4 Avergat - Driesberg gh Lahaye 2018 +6 6 Avergat - Grootberg 8310 Lahaye 2018 +5 5 Avergat - Putberg gh Lahaye 2018 +20 20 Coolen 8310 Limburgs Landschap 2020; pers. comm. Veerle Cielen (Limburgs Landschap vzw) +21 21 Coolen gh Limburgs Landschap 2020 +29 29 Groeve Lindestraat 8310 NA +31 31 Grote berg - centraal 8310 De Haan & Lahaye 2018 +37 37 Grote berg - Pauly 8310 De Haan & Lahaye 2018 +24 24 Henisdael - Champignonkuil 8310 Dusar et al. 2007 +34 34 Henisdael - Grote Kuil 8310 Dusar et al. 2007 +36 36 Henisdael - Hussenkuil noord 8310 Dusar et al. 2007 +27 27 Henisdael - Hussenkuil zuid 8310 Dusar et al. 2007 +25 25 Henisdael - Walenkuil 8310 Dusar et al. 2007 +26 26 Henisdael - Waterkuil VII 8310 Dusar et al. 2007 +35 35 Henisdael - Waterkuil VIII 8310 Dusar et al. 2007 +44 44 Jageneau's Huiske 8310 NA +28 28 Janekes Koet 8310 NA +32 32 Juge Zussen 8310 NA +1 1 Kuilen van Valmeer gh NA +2 2 Kuilen van Valmeer gh NA +3 3 Kuilen van Valmeer gh NA +30 30 Pitjesberg - centraal 8310 Jennekens & Hageman 2012 +38 38 Pitjesberg - Tiendenschuur 8310 Jennekens & Hageman 2012 +41 41 Roosburg - Flessenberg 8310 NA +40 40 Roosburg - Koeberg 8310 NA +33 33 Roosburg - Verbiestberg 8310 NA +39 39 Roosburg - Verbiestberg midden 8310 NA +22 22 Werken van Mathuus 8310 Walschot 2010 +23 23 Werken van Mathuus - Opkanne IV 8310 Walschot 2010 +7 106 Caestert 8310 Silvertant 2003, Verhoeven 2008 +8 106 Caestert NA Silvertant 2003, Verhoeven 2008 +13 100 De Keel 8310 Walschot 2010 +14 100 De Keel NA Walschot 2010 +45 101 De Keel - Balkon 8310 Walschot 2010 +18 102 Kleine Keel 8310 Walschot 2010 +19 102 Kleine Keel NA Walschot 2010 +15 103 Muizenberg gh Walschot 2010; Wikipedia 2019 +16 103 Muizenberg NA Walschot 2010; Wikipedia 2019 +17 103 Muizenberg gh Walschot 2010; Wikipedia 2019 +42 107 Roosburg - Drie-dagen-berg 8310 NA +43 107 Roosburg - Drie-dagen-berg NA NA +11 104 Ternaaien beneden 8310 Silvertant 2003, Verhoeven 2008 +12 104 Ternaaien beneden NA Silvertant 2003, Verhoeven 2008 +9 105 Ternaaien boven 8310 Silvertant 2003, Verhoeven 2008 +10 105 Ternaaien boven NA Silvertant 2003, Verhoeven 2008 diff --git a/src/generate_habitatquarries/generate_habitatquarries.Rproj b/src/generate_habitatquarries/generate_habitatquarries.Rproj new file mode 100644 index 0000000..cde2e35 --- /dev/null +++ b/src/generate_habitatquarries/generate_habitatquarries.Rproj @@ -0,0 +1,18 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: knitr +LaTeX: XeLaTeX + +AutoAppendNewline: Yes +StripTrailingWhitespace: Yes + +BuildType: Website diff --git a/src/generate_habitatquarries/index.Rmd b/src/generate_habitatquarries/index.Rmd new file mode 100644 index 0000000..f5fab6b --- /dev/null +++ b/src/generate_habitatquarries/index.Rmd @@ -0,0 +1,53 @@ +--- +title: "Preparing the raw data source habitatquarries" +# subtitle: "x" +date: "`r lubridate::now()`" +link-citations: true +linkcolor: link.colour +citecolor: link.colour +urlcolor: link.colour +geometry: margin=1in +mainfont: "Calibri" +fontsize: 11pt +documentclass: "article" +# csl: ../inbo.csl +# bibliography: ../references.bib +site: bookdown::bookdown_site +output: + bookdown::html_document2: + code_folding: show + keep_md: TRUE + number_sections: yes + fig_caption: yes + df_print: paged + toc: TRUE + toc_float: + collapsed: FALSE + smooth_scroll: FALSE + includes: + in_header: ../header.html +--- + +```{r setup, include=FALSE} +library(sf) +library(dplyr) +library(stringr) +library(purrr) +library(knitr) +library(rprojroot) +library(googledrive) +library(bib2df) +library(ggplot2) +library(readr) +opts_chunk$set( + echo = TRUE, + dpi = 300 +) +``` + +**Note: this is a bookdown project, supposed to be run from within the `src/generate_habitatquarries` subfolder. You can use the `generate_habitatquarries.Rproj` RStudio project file in this subfolder to run it.** + + + + + diff --git a/src/generate_habitatquarries/renv.lock b/src/generate_habitatquarries/renv.lock new file mode 100644 index 0000000..82cc818 --- /dev/null +++ b/src/generate_habitatquarries/renv.lock @@ -0,0 +1,829 @@ +{ + "R": { + "Version": "3.6.3", + "Repositories": [ + { + "Name": "RStudio", + "URL": "http://cloud.r-project.org" + }, + { + "Name": "INLA", + "URL": "https://inla.r-inla-download.org/R/stable" + }, + { + "Name": "inbo", + "URL": "https://inbo.github.io/drat" + } + ] + }, + "Packages": { + "BH": { + "Package": "BH", + "Version": "1.72.0-3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "8f9ce74c6417d61f0782cbae5fd2b7b0" + }, + "DBI": { + "Package": "DBI", + "Version": "1.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "4744be45519d675af66c28478720fce5" + }, + "DT": { + "Package": "DT", + "Version": "0.13", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a16cb2832248c7cff5a6f505e2aea45b" + }, + "KernSmooth": { + "Package": "KernSmooth", + "Version": "2.23-17", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "bbff70c8c0357b5b88238c83f680fcd3" + }, + "MASS": { + "Package": "MASS", + "Version": "7.3-51.6", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "1dad32ac9dbd8057167b2979fb932ff7" + }, + "Matrix": { + "Package": "Matrix", + "Version": "1.2-18", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "08588806cba69f04797dab50627428ed" + }, + "R6": { + "Package": "R6", + "Version": "2.4.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "292b54f8f4b94669b08f94e5acce6be2" + }, + "RColorBrewer": { + "Package": "RColorBrewer", + "Version": "1.1-2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "e031418365a7f7a766181ab5a41a5716" + }, + "Rcpp": { + "Package": "Rcpp", + "Version": "1.0.4.6", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "e652f23d8b1807cc975c51410d05b72f" + }, + "askpass": { + "Package": "askpass", + "Version": "1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "e8a22846fff485f0be3770c2da758713" + }, + "assertthat": { + "Package": "assertthat", + "Version": "0.2.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "50c838a310445e954bc13f26f26a6ecf" + }, + "backports": { + "Package": "backports", + "Version": "1.1.8", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "3ef0eac19317fd03c0c854aed581d473" + }, + "base64enc": { + "Package": "base64enc", + "Version": "0.1-3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "543776ae6848fde2f48ff3816d0628bc" + }, + "bib2df": { + "Package": "bib2df", + "Version": "1.1.2", + "Source": "GitHub", + "RemoteType": "github", + "RemoteHost": "api.github.com", + "RemoteRepo": "bib2df", + "RemoteUsername": "ropensci", + "RemoteRef": "master", + "RemoteSha": "04b2a2394dd743370a09b47e5c18dfd580efa74e", + "Hash": "d3934c6c0b404526704635dce522222a" + }, + "bookdown": { + "Package": "bookdown", + "Version": "0.19", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "4f669b7b4f236538e6afc311f32d2c93" + }, + "brew": { + "Package": "brew", + "Version": "1.0-6", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "92a5f887f9ae3035ac7afde22ba73ee9" + }, + "callr": { + "Package": "callr", + "Version": "3.4.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "643163a00cb536454c624883a10ae0bc" + }, + "class": { + "Package": "class", + "Version": "7.3-17", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "9267f5dab59a4ef44229858a142bded1" + }, + "classInt": { + "Package": "classInt", + "Version": "0.4-3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "17bdfa3c51df4a6c82484d13b11fb380" + }, + "cli": { + "Package": "cli", + "Version": "2.0.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ff0becff7bfdfe3f75d29aff8f3172dd" + }, + "clipr": { + "Package": "clipr", + "Version": "0.7.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "08cf4045c149a0f0eaf405324c7495bd" + }, + "colorspace": { + "Package": "colorspace", + "Version": "1.4-1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6b436e95723d1f0e861224dd9b094dfb" + }, + "commonmark": { + "Package": "commonmark", + "Version": "1.7", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "0f22be39ec1d141fd03683c06f3a6e67" + }, + "covr": { + "Package": "covr", + "Version": "3.5.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "cbc6df1ef6ee576f844f973c1fc04ab4" + }, + "crayon": { + "Package": "crayon", + "Version": "1.3.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "0d57bc8e27b7ba9e45dba825ebc0de6b" + }, + "crosstalk": { + "Package": "crosstalk", + "Version": "1.1.0.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ae55f5d7c02f0ab43c58dd050694f2b4" + }, + "curl": { + "Package": "curl", + "Version": "4.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "2b7d10581cc730804e9ed178c8374bd6" + }, + "desc": { + "Package": "desc", + "Version": "1.2.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6c8fe8fa26a23b79949375d372c7b395" + }, + "devtools": { + "Package": "devtools", + "Version": "2.3.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "d55dae3aa077e25128115a81e974f318" + }, + "digest": { + "Package": "digest", + "Version": "0.6.25", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "f697db7d92b7028c4b3436e9603fb636" + }, + "dplyr": { + "Package": "dplyr", + "Version": "1.0.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "4011f62581a34080e44105d4aa05a97f" + }, + "e1071": { + "Package": "e1071", + "Version": "1.7-3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "728e85416ffc90743054c1ac04486d69" + }, + "ellipsis": { + "Package": "ellipsis", + "Version": "0.3.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "fd2844b3a43ae2d27e70ece2df1b4e2a" + }, + "evaluate": { + "Package": "evaluate", + "Version": "0.14", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ec8ca05cffcc70569eaaad8469d2a3a7" + }, + "fansi": { + "Package": "fansi", + "Version": "0.4.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "7fce217eaaf8016e72065e85c73027b5" + }, + "farver": { + "Package": "farver", + "Version": "2.0.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "dad6793a5a1f73c8e91f1a1e3e834b05" + }, + "fs": { + "Package": "fs", + "Version": "1.4.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "780713bd2f53156fae001443dcdbdcd5" + }, + "gargle": { + "Package": "gargle", + "Version": "0.5.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "aaacaf8b0ec3dfe45df9eb6bc040db44" + }, + "generics": { + "Package": "generics", + "Version": "0.0.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "b8cff1d1391fd1ad8b65877f4c7f2e53" + }, + "ggplot2": { + "Package": "ggplot2", + "Version": "3.3.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "4ded8b439797f7b1693bd3d238d0106b" + }, + "gh": { + "Package": "gh", + "Version": "1.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "89ea5998938d1ad55f035c8a86f96b74" + }, + "git2r": { + "Package": "git2r", + "Version": "0.27.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "531a82d1beed1f545beb25f4f5945bf7" + }, + "glue": { + "Package": "glue", + "Version": "1.4.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "f43e0d5e85ccb0a4045670c0607ee504" + }, + "googledrive": { + "Package": "googledrive", + "Version": "1.0.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "79ba5d18133290a69b7c135dc3dfef1a" + }, + "gtable": { + "Package": "gtable", + "Version": "0.3.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ac5c6baf7822ce8732b343f14c072c4d" + }, + "highr": { + "Package": "highr", + "Version": "0.8", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "4dc5bb88961e347a0f4d8aad597cbfac" + }, + "hms": { + "Package": "hms", + "Version": "0.5.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "726671f634529d470545f9fd1a9d1869" + }, + "htmltools": { + "Package": "htmltools", + "Version": "0.5.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "7d651b7131794fe007b1ad6f21aaa401" + }, + "htmlwidgets": { + "Package": "htmlwidgets", + "Version": "1.5.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "41bace23583fbc25089edae324de2dc3" + }, + "httr": { + "Package": "httr", + "Version": "1.4.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "7146fea4685b4252ebf478978c75f597" + }, + "humaniformat": { + "Package": "humaniformat", + "Version": "0.6.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "d521cf9db39ca79250a00029661fb7cd" + }, + "ini": { + "Package": "ini", + "Version": "0.3.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6154ec2223172bce8162d4153cda21f7" + }, + "isoband": { + "Package": "isoband", + "Version": "0.2.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6e58bd3d6b3dd82a944cd6f05ade228f" + }, + "jsonlite": { + "Package": "jsonlite", + "Version": "1.6.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "84b0ee361e2f78d6b7d670db9471c0c5" + }, + "knitr": { + "Package": "knitr", + "Version": "1.28", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "915a6f0134cdbdf016d7778bc80b2eda" + }, + "labeling": { + "Package": "labeling", + "Version": "0.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "73832978c1de350df58108c745ed0e3e" + }, + "later": { + "Package": "later", + "Version": "1.1.0.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "d0a62b247165aabf397fded504660d8a" + }, + "lattice": { + "Package": "lattice", + "Version": "0.20-41", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "fbd9285028b0263d76d18c95ae51a53d" + }, + "lazyeval": { + "Package": "lazyeval", + "Version": "0.2.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "d908914ae53b04d4c0c0fd72ecc35370" + }, + "lifecycle": { + "Package": "lifecycle", + "Version": "0.2.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "361811f31f71f8a617a9a68bf63f1f42" + }, + "lubridate": { + "Package": "lubridate", + "Version": "1.7.9", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "fc1c91e2e8d9e1fc932e75aa1ed989b7" + }, + "magrittr": { + "Package": "magrittr", + "Version": "1.5", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "1bb58822a20301cee84a41678e25d9b7" + }, + "markdown": { + "Package": "markdown", + "Version": "1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "61e4a10781dd00d7d81dd06ca9b94e95" + }, + "memoise": { + "Package": "memoise", + "Version": "1.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "58baa74e4603fcfb9a94401c58c8f9b1" + }, + "mgcv": { + "Package": "mgcv", + "Version": "1.8-31", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "4bb7e0c4f3557583e1e8d3c9ffb8ba5c" + }, + "mime": { + "Package": "mime", + "Version": "0.9", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "e87a35ec73b157552814869f45a63aa3" + }, + "munsell": { + "Package": "munsell", + "Version": "0.5.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6dfe8bf774944bd5595785e3229d8771" + }, + "nlme": { + "Package": "nlme", + "Version": "3.1-148", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "662f52871983ff3e3ef042c62de126df" + }, + "openssl": { + "Package": "openssl", + "Version": "1.4.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "49f7258fd86ebeaea1df24d9ded00478" + }, + "pander": { + "Package": "pander", + "Version": "0.6.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "121198ce37b5a6b5227edc5a38223da4" + }, + "pillar": { + "Package": "pillar", + "Version": "1.4.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "b01d2494d0e2b6b02fae40e1543fbcb0" + }, + "pkgbuild": { + "Package": "pkgbuild", + "Version": "1.0.8", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "8d8b5e29223aabb829246397299f0592" + }, + "pkgconfig": { + "Package": "pkgconfig", + "Version": "2.0.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "01f28d4278f15c76cddbea05899c5d6f" + }, + "pkgload": { + "Package": "pkgload", + "Version": "1.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "b6b150cd4709e0c0c9b5d51ac4376282" + }, + "praise": { + "Package": "praise", + "Version": "1.0.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a555924add98c99d2f411e37e7d25e9f" + }, + "prettyunits": { + "Package": "prettyunits", + "Version": "1.1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "95ef9167b75dde9d2ccc3c7528393e7e" + }, + "processx": { + "Package": "processx", + "Version": "3.4.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "20a082f2bde0ffcd8755779fd476a274" + }, + "promises": { + "Package": "promises", + "Version": "1.1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a8730dcbdd19f9047774909f0ec214a4" + }, + "ps": { + "Package": "ps", + "Version": "1.3.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "425d938eb9c02906a8ac98c0c2a306b5" + }, + "purrr": { + "Package": "purrr", + "Version": "0.3.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "97def703420c8ab10d8f0e6c72101e02" + }, + "rcmdcheck": { + "Package": "rcmdcheck", + "Version": "1.3.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ed95895886dab6d2a584da45503555da" + }, + "readr": { + "Package": "readr", + "Version": "1.3.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "af8ab99cd936773a148963905736907b" + }, + "rematch2": { + "Package": "rematch2", + "Version": "2.1.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "76c9e04c712a05848ae7a23d2f170a40" + }, + "remotes": { + "Package": "remotes", + "Version": "2.1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "57c3009534f805f0f6476ffee68483cc" + }, + "renv": { + "Package": "renv", + "Version": "0.12.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "7340c71f46a0fd16506cfa804e224e44" + }, + "rex": { + "Package": "rex", + "Version": "1.2.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "093584b944440c5cd07a696b3c8e0e4c" + }, + "rlang": { + "Package": "rlang", + "Version": "0.4.6", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "aa263e3ce17b177c49e0daade2ee3cdc" + }, + "rmarkdown": { + "Package": "rmarkdown", + "Version": "2.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "aa82ab08b203d5a32a5b5f404e80c399" + }, + "roxygen2": { + "Package": "roxygen2", + "Version": "7.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "f173062c04dc8e91d7376d914df6efee" + }, + "rprojroot": { + "Package": "rprojroot", + "Version": "1.3-2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "f6a407ae5dd21f6f80a6708bbb6eb3ae" + }, + "rstudioapi": { + "Package": "rstudioapi", + "Version": "0.11", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "33a5b27a03da82ac4b1d43268f80088a" + }, + "rversions": { + "Package": "rversions", + "Version": "2.0.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "0ec41191f744d0f5afad8c6f35cc36e4" + }, + "scales": { + "Package": "scales", + "Version": "1.1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6f76f71042411426ec8df6c54f34e6dd" + }, + "sessioninfo": { + "Package": "sessioninfo", + "Version": "1.1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "308013098befe37484df72c39cf90d6e" + }, + "sf": { + "Package": "sf", + "Version": "0.9-5", + "Source": "GitHub", + "RemoteType": "github", + "RemoteHost": "api.github.com", + "RemoteRepo": "sf", + "RemoteUsername": "r-spatial", + "RemoteRef": "master", + "RemoteSha": "e0debeb55be814bc6d2f8d0903b17ce287bdcc6f", + "Hash": "25e78c6be953746f6dd1e2ffbbd978a4" + }, + "stringi": { + "Package": "stringi", + "Version": "1.4.6", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "e99d8d656980d2dd416a962ae55aec90" + }, + "stringr": { + "Package": "stringr", + "Version": "1.4.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "0759e6b6c0957edb1311028a49a35e76" + }, + "sys": { + "Package": "sys", + "Version": "3.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "507f3116a38d37ad330a038b3be07b66" + }, + "testthat": { + "Package": "testthat", + "Version": "2.3.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "0829b987b8961fb07f3b1b64a2fbc495" + }, + "tibble": { + "Package": "tibble", + "Version": "3.0.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "1c61e4cad000e03b1bd687db16a75926" + }, + "tidyselect": { + "Package": "tidyselect", + "Version": "1.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6ea435c354e8448819627cf686f66e0a" + }, + "tinytex": { + "Package": "tinytex", + "Version": "0.23", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a8c653ef8ce67683f588e6088ed45572" + }, + "units": { + "Package": "units", + "Version": "0.6-7", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "4a3df844d6d35ca2ba2b7ba95446b955" + }, + "usethis": { + "Package": "usethis", + "Version": "1.6.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "e1985f5a9985fea2e338fa7eb99018ca" + }, + "utf8": { + "Package": "utf8", + "Version": "1.1.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "4a5081acfb7b81a572e4384a7aaf2af1" + }, + "uuid": { + "Package": "uuid", + "Version": "0.1-4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "e4169eb989a5d03ccb6b628cad1b1b50" + }, + "vctrs": { + "Package": "vctrs", + "Version": "0.3.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "1739235995f08583db4095a28c357207" + }, + "viridisLite": { + "Package": "viridisLite", + "Version": "0.3.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ce4f6271baa94776db692f1cb2055bee" + }, + "whisker": { + "Package": "whisker", + "Version": "0.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ca970b96d894e90397ed20637a0c1bbe" + }, + "withr": { + "Package": "withr", + "Version": "2.2.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ecd17882a0b4419545691e095b74ee89" + }, + "xfun": { + "Package": "xfun", + "Version": "0.14", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "60e146e3aba37a547e12306dc3da77a6" + }, + "xml2": { + "Package": "xml2", + "Version": "1.3.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "d4d71a75dd3ea9eb5fa28cc21f9585e2" + }, + "xopen": { + "Package": "xopen", + "Version": "1.0.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6c85f015dee9cc7710ddd20f86881f58" + }, + "yaml": { + "Package": "yaml", + "Version": "2.2.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "2826c5d9efb0a88f657c7a679c7106db" + } + } +} diff --git a/src/generate_habitatquarries/renv/.gitignore b/src/generate_habitatquarries/renv/.gitignore new file mode 100644 index 0000000..82740ba --- /dev/null +++ b/src/generate_habitatquarries/renv/.gitignore @@ -0,0 +1,3 @@ +library/ +python/ +staging/ diff --git a/src/generate_habitatquarries/renv/activate.R b/src/generate_habitatquarries/renv/activate.R new file mode 100644 index 0000000..ff7e655 --- /dev/null +++ b/src/generate_habitatquarries/renv/activate.R @@ -0,0 +1,349 @@ + +local({ + + # the requested version of renv + version <- "0.12.0" + + # the project directory + project <- getwd() + + # avoid recursion + if (!is.na(Sys.getenv("RENV_R_INITIALIZING", unset = NA))) + return(invisible(TRUE)) + + # signal that we're loading renv during R startup + Sys.setenv("RENV_R_INITIALIZING" = "true") + on.exit(Sys.unsetenv("RENV_R_INITIALIZING"), add = TRUE) + + # signal that we've consented to use renv + options(renv.consent = TRUE) + + # load the 'utils' package eagerly -- this ensures that renv shims, which + # mask 'utils' packages, will come first on the search path + library(utils, lib.loc = .Library) + + # check to see if renv has already been loaded + if ("renv" %in% loadedNamespaces()) { + + # if renv has already been loaded, and it's the requested version of renv, + # nothing to do + spec <- .getNamespaceInfo(.getNamespace("renv"), "spec") + if (identical(spec[["version"]], version)) + return(invisible(TRUE)) + + # otherwise, unload and attempt to load the correct version of renv + unloadNamespace("renv") + + } + + # load bootstrap tools + bootstrap <- function(version, library) { + + # read repos (respecting override if set) + repos <- Sys.getenv("RENV_CONFIG_REPOS_OVERRIDE", unset = NA) + if (is.na(repos)) + repos <- getOption("repos") + + # fix up repos + on.exit(options(repos = repos), add = TRUE) + repos[repos == "@CRAN@"] <- "https://cloud.r-project.org" + options(repos = repos) + + # attempt to download renv + tarball <- tryCatch(renv_bootstrap_download(version), error = identity) + if (inherits(tarball, "error")) + stop("failed to download renv ", version) + + # now attempt to install + status <- tryCatch(renv_bootstrap_install(version, tarball, library), error = identity) + if (inherits(status, "error")) + stop("failed to install renv ", version) + + } + + renv_bootstrap_download_impl <- function(url, destfile) { + + mode <- "wb" + + # https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17715 + fixup <- + Sys.info()[["sysname"]] == "Windows" && + substring(url, 1L, 5L) == "file:" + + if (fixup) + mode <- "w+b" + + download.file( + url = url, + destfile = destfile, + mode = mode, + quiet = TRUE + ) + + } + + renv_bootstrap_download <- function(version) { + + methods <- list( + renv_bootstrap_download_cran_latest, + renv_bootstrap_download_cran_archive, + renv_bootstrap_download_github + ) + + for (method in methods) { + path <- tryCatch(method(version), error = identity) + if (is.character(path) && file.exists(path)) + return(path) + } + + stop("failed to download renv ", version) + + } + + renv_bootstrap_download_cran_latest <- function(version) { + + # check for renv on CRAN matching this version + db <- as.data.frame(available.packages(), stringsAsFactors = FALSE) + + entry <- db[db$Package %in% "renv" & db$Version %in% version, ] + if (nrow(entry) == 0) { + fmt <- "renv %s is not available from your declared package repositories" + stop(sprintf(fmt, version)) + } + + message("* Downloading renv ", version, " from CRAN ... ", appendLF = FALSE) + + info <- tryCatch( + download.packages("renv", destdir = tempdir()), + condition = identity + ) + + if (inherits(info, "condition")) { + message("FAILED") + return(FALSE) + } + + message("OK") + info[1, 2] + + } + + renv_bootstrap_download_cran_archive <- function(version) { + + name <- sprintf("renv_%s.tar.gz", version) + repos <- getOption("repos") + urls <- file.path(repos, "src/contrib/Archive/renv", name) + destfile <- file.path(tempdir(), name) + + message("* Downloading renv ", version, " from CRAN archive ... ", appendLF = FALSE) + + for (url in urls) { + + status <- tryCatch( + renv_bootstrap_download_impl(url, destfile), + condition = identity + ) + + if (identical(status, 0L)) { + message("OK") + return(destfile) + } + + } + + message("FAILED") + return(FALSE) + + } + + renv_bootstrap_download_github <- function(version) { + + enabled <- Sys.getenv("RENV_BOOTSTRAP_FROM_GITHUB", unset = "TRUE") + if (!identical(enabled, "TRUE")) + return(FALSE) + + # prepare download options + pat <- Sys.getenv("GITHUB_PAT") + if (nzchar(Sys.which("curl")) && nzchar(pat)) { + fmt <- "--location --fail --header \"Authorization: token %s\"" + extra <- sprintf(fmt, pat) + saved <- options("download.file.method", "download.file.extra") + options(download.file.method = "curl", download.file.extra = extra) + on.exit(do.call(base::options, saved), add = TRUE) + } else if (nzchar(Sys.which("wget")) && nzchar(pat)) { + fmt <- "--header=\"Authorization: token %s\"" + extra <- sprintf(fmt, pat) + saved <- options("download.file.method", "download.file.extra") + options(download.file.method = "wget", download.file.extra = extra) + on.exit(do.call(base::options, saved), add = TRUE) + } + + message("* Downloading renv ", version, " from GitHub ... ", appendLF = FALSE) + + url <- file.path("https://api.github.com/repos/rstudio/renv/tarball", version) + name <- sprintf("renv_%s.tar.gz", version) + destfile <- file.path(tempdir(), name) + + status <- tryCatch( + renv_bootstrap_download_impl(url, destfile), + condition = identity + ) + + if (!identical(status, 0L)) { + message("FAILED") + return(FALSE) + } + + message("Done!") + return(destfile) + + } + + renv_bootstrap_install <- function(version, tarball, library) { + + # attempt to install it into project library + message("* Installing renv ", version, " ... ", appendLF = FALSE) + dir.create(library, showWarnings = FALSE, recursive = TRUE) + + # invoke using system2 so we can capture and report output + bin <- R.home("bin") + exe <- if (Sys.info()[["sysname"]] == "Windows") "R.exe" else "R" + r <- file.path(bin, exe) + args <- c("--vanilla", "CMD", "INSTALL", "-l", shQuote(library), shQuote(tarball)) + output <- system2(r, args, stdout = TRUE, stderr = TRUE) + message("Done!") + + # check for successful install + status <- attr(output, "status") + if (is.numeric(status) && !identical(status, 0L)) { + header <- "Error installing renv:" + lines <- paste(rep.int("=", nchar(header)), collapse = "") + text <- c(header, lines, output) + writeLines(text, con = stderr()) + } + + status + + } + + renv_bootstrap_prefix <- function() { + + # construct version prefix + version <- paste(R.version$major, R.version$minor, sep = ".") + prefix <- paste("R", numeric_version(version)[1, 1:2], sep = "-") + + # include SVN revision for development versions of R + # (to avoid sharing platform-specific artefacts with released versions of R) + devel <- + identical(R.version[["status"]], "Under development (unstable)") || + identical(R.version[["nickname"]], "Unsuffered Consequences") + + if (devel) + prefix <- paste(prefix, R.version[["svn rev"]], sep = "-r") + + # build list of path components + components <- c(prefix, R.version$platform) + + # include prefix if provided by user + prefix <- Sys.getenv("RENV_PATHS_PREFIX") + if (nzchar(prefix)) + components <- c(prefix, components) + + # build prefix + paste(components, collapse = "/") + + } + + renv_bootstrap_library_root <- function(project) { + + path <- Sys.getenv("RENV_PATHS_LIBRARY", unset = NA) + if (!is.na(path)) + return(path) + + path <- Sys.getenv("RENV_PATHS_LIBRARY_ROOT", unset = NA) + if (!is.na(path)) + return(file.path(path, basename(project))) + + file.path(project, "renv/library") + + } + + renv_bootstrap_validate_version <- function(version) { + + loadedversion <- utils::packageDescription("renv", fields = "Version") + if (version == loadedversion) + return(TRUE) + + # assume four-component versions are from GitHub; three-component + # versions are from CRAN + components <- strsplit(loadedversion, "[.-]")[[1]] + remote <- if (length(components) == 4L) + paste("rstudio/renv", loadedversion, sep = "@") + else + paste("renv", loadedversion, sep = "@") + + fmt <- paste( + "renv %1$s was loaded from project library, but renv %2$s is recorded in lockfile.", + "Use `renv::record(\"%3$s\")` to record this version in the lockfile.", + "Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library.", + sep = "\n" + ) + + msg <- sprintf(fmt, loadedversion, version, remote) + warning(msg, call. = FALSE) + + FALSE + + } + + renv_bootstrap_load <- function(project, libpath, version) { + + # try to load renv from the project library + if (!requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) + return(FALSE) + + # warn if the version of renv loaded does not match + renv_bootstrap_validate_version(version) + + # load the project + renv::load(project) + + TRUE + + } + + # construct path to library root + root <- renv_bootstrap_library_root(project) + + # construct library prefix for platform + prefix <- renv_bootstrap_prefix() + + # construct full libpath + libpath <- file.path(root, prefix) + + # attempt to load + if (renv_bootstrap_load(project, libpath, version)) + return(TRUE) + + # load failed; attempt to bootstrap + bootstrap(version, libpath) + + # exit early if we're just testing bootstrap + if (!is.na(Sys.getenv("RENV_BOOTSTRAP_INSTALL_ONLY", unset = NA))) + return(TRUE) + + # try again to load + if (requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) { + message("Successfully installed and loaded renv ", version, ".") + return(renv::load()) + } + + # failed to download or load renv; warn the user + msg <- c( + "Failed to find an renv installation: the project will not be loaded.", + "Use `renv::activate()` to re-initialize the project." + ) + + warning(paste(msg, collapse = "\n"), call. = FALSE) + +}) diff --git a/src/generate_habitatquarries/renv/settings.dcf b/src/generate_habitatquarries/renv/settings.dcf new file mode 100644 index 0000000..11a53ea --- /dev/null +++ b/src/generate_habitatquarries/renv/settings.dcf @@ -0,0 +1,6 @@ +external.libraries: +ignored.packages: +package.dependency.fields: Imports, Depends, LinkingTo +snapshot.type: implicit +use.cache: TRUE +vcs.ignore.library: TRUE