Skip to content

Commit

Permalink
add renv + bootstrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
pfuehrlich-pik committed Oct 14, 2022
1 parent 7319f64 commit 72645ce
Show file tree
Hide file tree
Showing 6 changed files with 1,055 additions and 20 deletions.
37 changes: 17 additions & 20 deletions .Rprofile
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
# source global .Rprofile (very important to load user specific settings)
# DO NOT EDIT THIS LINE!
if(file.exists("~/.Rprofile")) source("~/.Rprofile")
source("renv/activate.R")

if (!"https://rse.pik-potsdam.de/r/packages" %in% getOption("repos")) {
options(repos = c(getOption("repos"), pik = "https://rse.pik-potsdam.de/r/packages"))
}

# This profile can be used to link the model to a specified library snapshot
# (e.g. if your model version is from an older date and does not work with the
# newest libraries anymore)
# By default it is not active. Just uncomment the following lines and set the
# snapshot path to a path of your choice
# Please make also sure that in your config file this .Rprofile file is copied
# to the model output folder. Otherwise, the run itself will again use the
# default library set!
# bootstrapping, will only run once after this repo is freshly cloned
if (isTRUE(rownames(installed.packages(priority = "NA")) == "renv")) {
message("R package dependencies are not installed in this renv, installing now...")
renv::install("yaml", prompt = FALSE) # yaml is required to find dependencies in Rmd files
renv::hydrate() # auto-detect and install all dependencies
renv::snapshot(prompt = FALSE) # create renv.lock
message("Finished installing R package dependencies.")
}

# PLEASE NOTE: snapshots ending with '_R4' require R 4.1 (piam/1.24 and newer),
# other snapshots require R 3.6 (piam/1.20)
# snapshot <- "/p/projects/rd3mod/R/libraries/snapshots/2020_03_10"
# if(file.exists(snapshot)) {
# cat("Setting libPaths to",snapshot,"\n")
# .libPaths(snapshot)
# } else {
# cat("Could not find",snapshot,"\n")
# }
# source global .Rprofile (very important to load user specific settings)
# DO NOT EDIT THIS LINE!
if (file.exists("~/.Rprofile")) {
source("~/.Rprofile")
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ Rplots.pdf

#ignore GAMS license
gamslice.txt

#ignore lock file
/.lock
23 changes: 23 additions & 0 deletions .snapshot.Rprofile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# source global .Rprofile (very important to load user specific settings)
# DO NOT EDIT THIS LINE!
if(file.exists("~/.Rprofile")) source("~/.Rprofile")


# This profile can be used to link the model to a specified library snapshot
# (e.g. if your model version is from an older date and does not work with the
# newest libraries anymore)
# By default it is not active. Just uncomment the following lines and set the
# snapshot path to a path of your choice
# Please make also sure that in your config file this .Rprofile file is copied
# to the model output folder. Otherwise, the run itself will again use the
# default library set!

# PLEASE NOTE: snapshots ending with '_R4' require R 4.1 (piam/1.24 and newer),
# other snapshots require R 3.6 (piam/1.20)
# snapshot <- "/p/projects/rd3mod/R/libraries/snapshots/2020_03_10"
# if(file.exists(snapshot)) {
# cat("Setting libPaths to",snapshot,"\n")
# .libPaths(snapshot)
# } else {
# cat("Could not find",snapshot,"\n")
# }
8 changes: 8 additions & 0 deletions renv/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
library/
local/
cellar/
lock/
python/
sandbox/
staging/
archive/
Loading

0 comments on commit 72645ce

Please sign in to comment.