-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
272 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#' @title Options for the zcurve package | ||
#' | ||
#' @description A placeholder object and functions for the zcurve package. | ||
#' (adapted from the runjags R package). | ||
#' | ||
#' @param name the name of the option to get the current value of - for a list of | ||
#' available options, see details below. | ||
#' @param ... named option(s) to change - for a list of available options, see | ||
#' details below. | ||
#' | ||
#' @return The current value of all available zcurve options (after applying any | ||
#' changes specified) is returned invisibly as a named list. | ||
#' | ||
#' @export zcurve.options | ||
#' @export zcurve.get_option | ||
#' @name zcurve_options | ||
#' @aliases zcurve_options zcurve.options zcurve.get_option | ||
NULL | ||
|
||
|
||
#' @rdname zcurve_options | ||
zcurve.options <- function(...){ | ||
|
||
opts <- list(...) | ||
|
||
for(i in seq_along(opts)){ | ||
|
||
if(!names(opts)[i] %in% names(zcurve.private)) | ||
stop(paste("Unmatched or ambiguous option '", names(opts)[i], "'", sep="")) | ||
|
||
assign(names(opts)[i], opts[[i]] , envir = zcurve.private) | ||
} | ||
|
||
return(invisible(zcurve.private$options)) | ||
} | ||
|
||
#' @rdname zcurve_options | ||
zcurve.get_option <- function(name){ | ||
|
||
if(length(name)!=1) | ||
stop("Only 1 option can be retrieved at a time") | ||
|
||
if(!name %in% names(zcurve.private)) | ||
stop(paste("Unmatched or ambiguous option '", name, "'", sep="")) | ||
|
||
# Use eval as some defaults are put in using 'expression' to avoid evaluating at load time: | ||
return(eval(zcurve.private[[name]])) | ||
} | ||
|
||
|
||
zcurve.private <- new.env() | ||
# Use 'expression' for functions to avoid having to evaluate before the package is fully loaded: | ||
assign("defaultoptions", list(envir = zcurve.private)) | ||
|
||
assign("options", zcurve.private$defaultoptions, envir = zcurve.private) | ||
assign("max_cores", parallel::detectCores(logical = TRUE) - 1, envir = zcurve.private) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.