Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 78 packages #21

Merged
merged 8 commits into from
Jul 7, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ po/*~

# renv sandbox needed for renv version 0.16.0
renv/sandbox # OPTIONAL
renv/sandbox
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ episodes:
- TallerIntroAnaliticaBrotes.Rmd
- ZIKAB.Rmd
- EnfermedadX.Rmd
- EnfermedadX2.Rmd
#- EnfermedadX2.Rmd
- Sivirep-tutorial.Rmd
- Serofoi-tutorial.Rmd
- Vaccineff-tutorial.Rmd
Expand Down
13 changes: 5 additions & 8 deletions episodes/Serofoi-tutorial.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -404,14 +404,14 @@ mismo, corra las siguientes líneas de código:
```{r chik2015_constant, include = TRUE, echo = TRUE, eval = FALSE}
chik_constant <- run_seromodel(serodata = chik2015p,
foi_model = "constant",
n_iters = 1000)
iter = 1000)

chik_constant_plot <- plot_seromodel(chik_constant,
serodata = chik2015p,
size_text = 12)
```

Ahora, corra los modelos dependientes del tiempo con `n_iters =1500`.
Ahora, corra los modelos dependientes del tiempo con `iter =1500`.
Luego visualice conjuntamente las tres gráficas por medio de la función
`plot_grid()` del paquete `cowplot`:

Expand All @@ -435,18 +435,15 @@ minutos.
# Implementation of the models
m1_chik <- run_seromodel(serodata = chik2015p,
foi_model = "constant",
n_iters = 1000,
n_thin = 2)
iter = 1000)

m2_chik <- run_seromodel(serodata = chik2015p,
foi_model = "tv_normal",
n_iters = 1500,
n_thin = 2)
iter = 1500)

m3_chik <- run_seromodel(serodata = chik2015p,
foi_model = "tv_normal_log",
n_iters = 1500,
n_thin = 2)
iter = 1500)
```

```{r chik2015_vis, include = TRUE, echo = FALSE, results="hide", errors = FALSE, warning = FALSE, message = FALSE, fig.width=5, fig.asp=1, fig.align="center", fig.keep="all"}
Expand Down
14 changes: 7 additions & 7 deletions episodes/epiCo-tutorial.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ head(divipola_table)
Los usuarios pueden realizar consultas a **epiCo** utilizando la función `population_pyramid`, la cual requiere el codigo DIVIPOLA de la entidad de interés y el año que se desea consultar.

```{r}
tolima_codigo <- 73 # Código DIVIPOLA para el departamento del Tolima.
tolima_codigo <- "73" # Código DIVIPOLA para el departamento del Tolima.
año <- 2021 # Año a consultar.
tolima_piramide_2021 <- population_pyramid(tolima_codigo, año) # Pirámide
# poblacional del departamento del tolima para el año 2021.
Expand All @@ -99,14 +99,14 @@ head(tolima_piramide_2021)
**epiCo** presenta los datos agrupados en intervalos de 5 años *de forma predeterminada*; sin embargo, puede modificar parámetros para tener rangos distintos, separar la pirámide por género binario, obtener los datos como conteos totales o proporciones y/o desplegar una gráfica de la pirámide.

```{r}
tolima_codigo <- 73 # Código DIVIPOLA para el departamento del Tolima.
tolima_codigo <- "73" # Código DIVIPOLA para el departamento del Tolima.
año <- 2021 # Año a consultar.
rango_edad <- 10 #Rango de edades o ventana.
# Pirámide poblacional del departamento del tolima para el año 2021.
tolima_piramide_2021 <- population_pyramid(divipola_code = tolima_codigo,
year = año,
range = rango_edad,
gender = TRUE, total = TRUE,
sex = TRUE, total = TRUE,
plot = TRUE)
```

Expand Down Expand Up @@ -135,7 +135,7 @@ Para calcular la distribución de las ocupaciones en estos años, **epiCo** usa
data("isco88_table")
head(isco88_table)
# Se calcula la distribución de ocupaciones.
occupation_plot(isco_codes = as.integer(epi_data$ocupacion), gender = epi_data$sexo)
describe_occupation(isco_codes = as.integer(epi_data$ocupacion), sex = epi_data$sexo,plot = "treemap")
```

### 5. Estimación de las tasas de incidencia
Expand Down Expand Up @@ -168,7 +168,7 @@ data_tolima_2021 <- epi_data[lubridate::year(epi_data$fec_not) == 2021, ]
# Se calcula las tasas por edades para el año 2021.
incidence_rate_2019 <- age_risk(age = as.integer(data_tolima_2021$edad),
population_pyramid = tolima_piramide_2021,
gender = data_tolima_2021$sexo,
sex = data_tolima_2021$sexo,
plot = TRUE)
```

Expand Down Expand Up @@ -317,8 +317,8 @@ incidence_object <- incidence(

# Se realiza el analisis espaciotemporal, especificando la escala de nivel
# municipal
monrans_tolima <- morans_index(incidence_object = incidence_object, level = 2)
monrans_tolima$leaflet_map
monrans_tolima <- morans_index(incidence_object = incidence_object, threshold = 2)
monrans_tolima$plot
```


Expand Down
80 changes: 60 additions & 20 deletions renv/activate.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
local({

# the requested version of renv
version <- "1.0.3"
version <- "1.0.7"
attr(version, "sha") <- NULL

# the project directory
project <- getwd()
project <- Sys.getenv("RENV_PROJECT")
if (!nzchar(project))
project <- getwd()

# use start-up diagnostics if enabled
diagnostics <- Sys.getenv("RENV_STARTUP_DIAGNOSTICS", unset = "FALSE")
Expand All @@ -31,6 +33,14 @@ local({
if (!is.null(override))
return(override)

# if we're being run in a context where R_LIBS is already set,
# don't load -- presumably we're being run as a sub-process and
# the parent process has already set up library paths for us
rcmd <- Sys.getenv("R_CMD", unset = NA)
rlibs <- Sys.getenv("R_LIBS", unset = NA)
if (!is.na(rlibs) && !is.na(rcmd))
return(FALSE)

# next, check environment variables
# TODO: prefer using the configuration one in the future
envvars <- c(
Expand All @@ -50,9 +60,22 @@ local({

})

if (!enabled)
# bail if we're not enabled
if (!enabled) {

# if we're not enabled, we might still need to manually load
# the user profile here
profile <- Sys.getenv("R_PROFILE_USER", unset = "~/.Rprofile")
if (file.exists(profile)) {
cfg <- Sys.getenv("RENV_CONFIG_USER_PROFILE", unset = "TRUE")
if (tolower(cfg) %in% c("true", "t", "1"))
sys.source(profile, envir = globalenv())
}

return(FALSE)

}

# avoid recursion
if (identical(getOption("renv.autoloader.running"), TRUE)) {
warning("ignoring recursive attempt to run renv autoloader")
Expand Down Expand Up @@ -108,6 +131,21 @@ local({

}

heredoc <- function(text, leave = 0) {

# remove leading, trailing whitespace
trimmed <- gsub("^\\s*\\n|\\n\\s*$", "", text)

# split into lines
lines <- strsplit(trimmed, "\n", fixed = TRUE)[[1L]]

# compute common indent
indent <- regexpr("[^[:space:]]", lines)
common <- min(setdiff(indent, -1L)) - leave
paste(substring(lines, common), collapse = "\n")

}

startswith <- function(string, prefix) {
substring(string, 1, nchar(prefix)) == prefix
}
Expand Down Expand Up @@ -610,6 +648,9 @@ local({

# if the user has requested an automatic prefix, generate it
auto <- Sys.getenv("RENV_PATHS_PREFIX_AUTO", unset = NA)
if (is.na(auto) && getRversion() >= "4.4.0")
auto <- "TRUE"

if (auto %in% c("TRUE", "True", "true", "1"))
return(renv_bootstrap_platform_prefix_auto())

Expand Down Expand Up @@ -801,24 +842,23 @@ local({

# the loaded version of renv doesn't match the requested version;
# give the user instructions on how to proceed
remote <- if (!is.null(description[["RemoteSha"]])) {
dev <- identical(description[["RemoteType"]], "github")
remote <- if (dev)
paste("rstudio/renv", description[["RemoteSha"]], sep = "@")
} else {
else
paste("renv", description[["Version"]], sep = "@")
}

# display both loaded version + sha if available
friendly <- renv_bootstrap_version_friendly(
version = description[["Version"]],
sha = description[["RemoteSha"]]
sha = if (dev) description[["RemoteSha"]]
)

fmt <- paste(
"renv %1$s was loaded from project library, but this project is configured to use renv %2$s.",
"- Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile.",
"- Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library.",
sep = "\n"
)
fmt <- heredoc("
renv %1$s was loaded from project library, but this project is configured to use renv %2$s.
- Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile.
- Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library.
")
catf(fmt, friendly, renv_bootstrap_version_friendly(version), remote)

FALSE
Expand Down Expand Up @@ -1041,7 +1081,7 @@ local({
# if jsonlite is loaded, use that instead
if ("jsonlite" %in% loadedNamespaces()) {

json <- catch(renv_json_read_jsonlite(file, text))
json <- tryCatch(renv_json_read_jsonlite(file, text), error = identity)
if (!inherits(json, "error"))
return(json)

Expand All @@ -1050,7 +1090,7 @@ local({
}

# otherwise, fall back to the default JSON reader
json <- catch(renv_json_read_default(file, text))
json <- tryCatch(renv_json_read_default(file, text), error = identity)
if (!inherits(json, "error"))
return(json)

Expand All @@ -1063,14 +1103,14 @@ local({
}

renv_json_read_jsonlite <- function(file = NULL, text = NULL) {
text <- paste(text %||% read(file), collapse = "\n")
text <- paste(text %||% readLines(file, warn = FALSE), collapse = "\n")
jsonlite::fromJSON(txt = text, simplifyVector = FALSE)
}

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

# find strings in the JSON
text <- paste(text %||% read(file), collapse = "\n")
text <- paste(text %||% readLines(file, warn = FALSE), collapse = "\n")
pattern <- '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
locs <- gregexpr(pattern, text, perl = TRUE)[[1]]

Expand Down Expand Up @@ -1118,14 +1158,14 @@ local({
map <- as.list(map)

# remap strings in object
remapped <- renv_json_remap(json, map)
remapped <- renv_json_read_remap(json, map)

# evaluate
eval(remapped, envir = baseenv())

}

renv_json_remap <- function(json, map) {
renv_json_read_remap <- function(json, map) {

# fix names
if (!is.null(names(json))) {
Expand All @@ -1152,7 +1192,7 @@ local({
# recurse
if (is.recursive(json)) {
for (i in seq_along(json)) {
json[i] <- list(renv_json_remap(json[[i]], map))
json[i] <- list(renv_json_read_remap(json[[i]], map))
}
}

Expand Down
Loading
Loading