Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions episodes/contact-matrices.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ The R package `{socialmixr}` contains functions which can estimate contact matri
polymod <- socialmixr::polymod
```

Then we can obtain the contact matrix for the age categories we want by specifying `age.limits`.
Then we can obtain the contact matrix for the age categories we want by specifying `age_limits`.

```{r polymod_uk, echo = TRUE}
contact_data <- socialmixr::contact_matrix(
survey = polymod,
countries = "United Kingdom",
age.limits = c(0, 20, 40),
age_limits = c(0, 20, 40),
symmetric = TRUE
)
contact_data
Expand Down Expand Up @@ -184,7 +184,7 @@ Similar to the code above, to access vector values within a dataframe, you can u
contact_data_zambia <- socialmixr::contact_matrix(
survey = zambia_sa_survey,
countries = "Zambia", # key argument
age.limits = c(0, 20),
age_limits = c(0, 20),
symmetric = TRUE
)

Expand Down Expand Up @@ -319,7 +319,7 @@ Normalisation can be performed by the function `contact_matrix()` in `{socialmix
contact_data_split <- socialmixr::contact_matrix(
survey = polymod,
countries = "United Kingdom",
age.limits = c(0, 20, 40),
age_limits = c(0, 20, 40),
symmetric = TRUE,
split = TRUE
)
Expand Down
2 changes: 1 addition & 1 deletion episodes/disease-burden.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ polymod <- socialmixr::polymod
contact_data <- socialmixr::contact_matrix(
polymod,
countries = "United Kingdom",
age.limits = c(0, 20, 40),
age_limits = c(0, 20, 40),
symmetric = TRUE
)

Expand Down
2 changes: 1 addition & 1 deletion episodes/modelling-interventions.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ survey_data <- socialmixr::polymod
cm_results <- socialmixr::contact_matrix(
survey = survey_data,
countries = "United Kingdom",
age.limits = c(0, 15, 65),
age_limits = c(0, 15, 65),
symmetric = TRUE
)

Expand Down
2 changes: 1 addition & 1 deletion episodes/simulating-transmission.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ polymod <- socialmixr::polymod
contact_data <- socialmixr::contact_matrix(
polymod,
countries = "United Kingdom",
age.limits = c(0, 20, 40),
age_limits = c(0, 20, 40),
symmetric = TRUE
)

Expand Down
2 changes: 1 addition & 1 deletion episodes/vaccine-comparisons.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ polymod <- socialmixr::polymod
contact_data <- socialmixr::contact_matrix(
polymod,
countries = "United Kingdom",
age.limits = c(0, 15, 65),
age_limits = c(0, 15, 65),
symmetric = TRUE
)

Expand Down
101 changes: 93 additions & 8 deletions renv/activate.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
local({

# the requested version of renv
version <- "1.1.5"
version <- "1.1.7"
attr(version, "md5") <- "dd5d60f155dadff4c88c2fc6680504b4"
attr(version, "sha") <- NULL

# the project directory
Expand Down Expand Up @@ -168,6 +169,16 @@ local({
if (quiet)
return(invisible())

# also check for config environment variables that should suppress messages
# https://github.com/rstudio/renv/issues/2214
enabled <- Sys.getenv("RENV_CONFIG_STARTUP_QUIET", unset = NA)
if (!is.na(enabled) && tolower(enabled) %in% c("true", "1"))
return(invisible())

enabled <- Sys.getenv("RENV_CONFIG_SYNCHRONIZED_CHECK", unset = NA)
if (!is.na(enabled) && tolower(enabled) %in% c("false", "0"))
return(invisible())

msg <- sprintf(fmt, ...)
cat(msg, file = stdout(), sep = if (appendLF) "\n" else "")

Expand Down Expand Up @@ -215,6 +226,16 @@ local({
section <- header(sprintf("Bootstrapping renv %s", friendly))
catf(section)

# try to install renv from cache
md5 <- attr(version, "md5", exact = TRUE)
if (length(md5)) {
pkgpath <- renv_bootstrap_find(version)
if (length(pkgpath) && file.exists(pkgpath)) {
file.copy(pkgpath, library, recursive = TRUE)
return(invisible())
}
}

# attempt to download renv
catf("- Downloading renv ... ", appendLF = FALSE)
withCallingHandlers(
Expand All @@ -240,7 +261,6 @@ local({

# add empty line to break up bootstrapping from normal output
catf("")

return(invisible())
}

Expand All @@ -257,12 +277,20 @@ local({
repos <- Sys.getenv("RENV_CONFIG_REPOS_OVERRIDE", unset = NA)
if (!is.na(repos)) {

# check for RSPM; if set, use a fallback repository for renv
rspm <- Sys.getenv("RSPM", unset = NA)
if (identical(rspm, repos))
repos <- c(RSPM = rspm, CRAN = cran)
# split on ';' if present
parts <- strsplit(repos, ";", fixed = TRUE)[[1L]]

return(repos)
# split into named repositories if present
idx <- regexpr("=", parts, fixed = TRUE)
keys <- substring(parts, 1L, idx - 1L)
vals <- substring(parts, idx + 1L)
names(vals) <- keys

# if we have a single unnamed repository, call it CRAN
if (length(vals) == 1L && identical(keys, ""))
names(vals) <- "CRAN"

return(vals)

}

Expand Down Expand Up @@ -511,6 +539,51 @@ local({

}

renv_bootstrap_find <- function(version) {

path <- renv_bootstrap_find_cache(version)
if (length(path) && file.exists(path)) {
catf("- Using renv %s from global package cache", version)
return(path)
}

}

renv_bootstrap_find_cache <- function(version) {

md5 <- attr(version, "md5", exact = TRUE)
if (is.null(md5))
return()

# infer path to renv cache
cache <- Sys.getenv("RENV_PATHS_CACHE", unset = "")
if (!nzchar(cache)) {
root <- Sys.getenv("RENV_PATHS_ROOT", unset = NA)
if (!is.na(root))
cache <- file.path(root, "cache")
}

if (!nzchar(cache)) {
tools <- asNamespace("tools")
if (is.function(tools$R_user_dir)) {
root <- tools$R_user_dir("renv", "cache")
cache <- file.path(root, "cache")
}
}

# start completing path to cache
file.path(
cache,
renv_bootstrap_cache_version(),
renv_bootstrap_platform_prefix(),
"renv",
version,
md5,
"renv"
)

}

renv_bootstrap_download_tarball <- function(version) {

# if the user has provided the path to a tarball via
Expand Down Expand Up @@ -979,7 +1052,7 @@ local({

renv_bootstrap_validate_version_release <- function(version, description) {
expected <- description[["Version"]]
is.character(expected) && identical(expected, version)
is.character(expected) && identical(c(expected), c(version))
}

renv_bootstrap_hash_text <- function(text) {
Expand Down Expand Up @@ -1181,6 +1254,18 @@ local({

}

renv_bootstrap_cache_version <- function() {
# NOTE: users should normally not override the cache version;
# this is provided just to make testing easier
Sys.getenv("RENV_CACHE_VERSION", unset = "v5")
}

renv_bootstrap_cache_version_previous <- function() {
version <- renv_bootstrap_cache_version()
number <- as.integer(substring(version, 2L))
paste("v", number - 1L, sep = "")
}

renv_json_read <- function(file = NULL, text = NULL) {

jlerr <- NULL
Expand Down
Loading
Loading