mirror of
https://github.com/agdamsbo/FreesearchR.git
synced 2026-06-19 04:27:30 +02:00
updated docs + boxplot
This commit is contained in:
parent
04784a7a24
commit
111393c73f
23 changed files with 908 additions and 306 deletions
|
|
@ -2,7 +2,7 @@
|
|||
local({
|
||||
|
||||
# the requested version of renv
|
||||
version <- "1.1.2"
|
||||
version <- "1.1.3"
|
||||
attr(version, "sha") <- NULL
|
||||
|
||||
# the project directory
|
||||
|
|
@ -695,11 +695,19 @@ local({
|
|||
|
||||
}
|
||||
|
||||
renv_bootstrap_platform_prefix <- function() {
|
||||
renv_bootstrap_platform_prefix_default <- function() {
|
||||
|
||||
# construct version prefix
|
||||
version <- paste(R.version$major, R.version$minor, sep = ".")
|
||||
prefix <- paste("R", numeric_version(version)[1, 1:2], sep = "-")
|
||||
# read version component
|
||||
version <- Sys.getenv("RENV_PATHS_VERSION", unset = "R-%v")
|
||||
|
||||
# expand placeholders
|
||||
placeholders <- list(
|
||||
list("%v", format(getRversion()[1, 1:2])),
|
||||
list("%V", format(getRversion()[1, 1:3]))
|
||||
)
|
||||
|
||||
for (placeholder in placeholders)
|
||||
version <- gsub(placeholder[[1L]], placeholder[[2L]], version, fixed = TRUE)
|
||||
|
||||
# include SVN revision for development versions of R
|
||||
# (to avoid sharing platform-specific artefacts with released versions of R)
|
||||
|
|
@ -708,10 +716,19 @@ local({
|
|||
identical(R.version[["nickname"]], "Unsuffered Consequences")
|
||||
|
||||
if (devel)
|
||||
prefix <- paste(prefix, R.version[["svn rev"]], sep = "-r")
|
||||
version <- paste(version, R.version[["svn rev"]], sep = "-r")
|
||||
|
||||
version
|
||||
|
||||
}
|
||||
|
||||
renv_bootstrap_platform_prefix <- function() {
|
||||
|
||||
# construct version prefix
|
||||
version <- renv_bootstrap_platform_prefix_default()
|
||||
|
||||
# build list of path components
|
||||
components <- c(prefix, R.version$platform)
|
||||
components <- c(version, R.version$platform)
|
||||
|
||||
# include prefix if provided by user
|
||||
prefix <- renv_bootstrap_platform_prefix_impl()
|
||||
|
|
@ -950,14 +967,14 @@ local({
|
|||
}
|
||||
|
||||
renv_bootstrap_validate_version_dev <- function(version, description) {
|
||||
|
||||
|
||||
expected <- description[["RemoteSha"]]
|
||||
if (!is.character(expected))
|
||||
return(FALSE)
|
||||
|
||||
|
||||
pattern <- sprintf("^\\Q%s\\E", version)
|
||||
grepl(pattern, expected, perl = TRUE)
|
||||
|
||||
|
||||
}
|
||||
|
||||
renv_bootstrap_validate_version_release <- function(version, description) {
|
||||
|
|
@ -1198,86 +1215,89 @@ local({
|
|||
}
|
||||
|
||||
renv_json_read_patterns <- function() {
|
||||
|
||||
|
||||
list(
|
||||
|
||||
|
||||
# objects
|
||||
list("{", "\t\n\tobject(\t\n\t"),
|
||||
list("}", "\t\n\t)\t\n\t"),
|
||||
|
||||
list("{", "\t\n\tobject(\t\n\t", TRUE),
|
||||
list("}", "\t\n\t)\t\n\t", TRUE),
|
||||
|
||||
# arrays
|
||||
list("[", "\t\n\tarray(\t\n\t"),
|
||||
list("]", "\n\t\n)\n\t\n"),
|
||||
|
||||
list("[", "\t\n\tarray(\t\n\t", TRUE),
|
||||
list("]", "\n\t\n)\n\t\n", TRUE),
|
||||
|
||||
# maps
|
||||
list(":", "\t\n\t=\t\n\t")
|
||||
|
||||
list(":", "\t\n\t=\t\n\t", TRUE),
|
||||
|
||||
# newlines
|
||||
list("\\u000a", "\n", FALSE)
|
||||
|
||||
)
|
||||
|
||||
|
||||
}
|
||||
|
||||
renv_json_read_envir <- function() {
|
||||
|
||||
envir <- new.env(parent = emptyenv())
|
||||
|
||||
|
||||
envir[["+"]] <- `+`
|
||||
envir[["-"]] <- `-`
|
||||
|
||||
|
||||
envir[["object"]] <- function(...) {
|
||||
result <- list(...)
|
||||
names(result) <- as.character(names(result))
|
||||
result
|
||||
}
|
||||
|
||||
|
||||
envir[["array"]] <- list
|
||||
|
||||
|
||||
envir[["true"]] <- TRUE
|
||||
envir[["false"]] <- FALSE
|
||||
envir[["null"]] <- NULL
|
||||
|
||||
|
||||
envir
|
||||
|
||||
|
||||
}
|
||||
|
||||
renv_json_read_remap <- function(object, patterns) {
|
||||
|
||||
|
||||
# repair names if necessary
|
||||
if (!is.null(names(object))) {
|
||||
|
||||
|
||||
nms <- names(object)
|
||||
for (pattern in patterns)
|
||||
nms <- gsub(pattern[[2L]], pattern[[1L]], nms, fixed = TRUE)
|
||||
names(object) <- nms
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
# repair strings if necessary
|
||||
if (is.character(object)) {
|
||||
for (pattern in patterns)
|
||||
object <- gsub(pattern[[2L]], pattern[[1L]], object, fixed = TRUE)
|
||||
}
|
||||
|
||||
|
||||
# recurse for other objects
|
||||
if (is.recursive(object))
|
||||
for (i in seq_along(object))
|
||||
object[i] <- list(renv_json_read_remap(object[[i]], patterns))
|
||||
|
||||
|
||||
# return remapped object
|
||||
object
|
||||
|
||||
|
||||
}
|
||||
|
||||
renv_json_read_default <- function(file = NULL, text = NULL) {
|
||||
|
||||
# read json text
|
||||
text <- paste(text %||% readLines(file, warn = FALSE), collapse = "\n")
|
||||
|
||||
|
||||
# convert into something the R parser will understand
|
||||
patterns <- renv_json_read_patterns()
|
||||
transformed <- text
|
||||
for (pattern in patterns)
|
||||
transformed <- gsub(pattern[[1L]], pattern[[2L]], transformed, fixed = TRUE)
|
||||
|
||||
|
||||
# parse it
|
||||
rfile <- tempfile("renv-json-", fileext = ".R")
|
||||
on.exit(unlink(rfile), add = TRUE)
|
||||
|
|
@ -1287,9 +1307,10 @@ local({
|
|||
# evaluate in safe environment
|
||||
result <- eval(json, envir = renv_json_read_envir())
|
||||
|
||||
# fix up strings if necessary
|
||||
# fix up strings if necessary -- do so only with reversible patterns
|
||||
patterns <- Filter(function(pattern) pattern[[3L]], patterns)
|
||||
renv_json_read_remap(result, patterns)
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue