R Under development (unstable) (2023-06-13 r84537 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(quantmod) Loading required package: xts Loading required package: zoo Attaching package: 'zoo' The following objects are masked from 'package:base': as.Date, as.Date.numeric Loading required package: TTR Registered S3 method overwritten by 'quantmod': method from as.zoo.data.frame zoo > > api.key <- "abc" > src <- "xyz" > > # {{{ Unexported function > > ### function name as character > ### -------------------------- > > ## default argument as character > # set > setDefaults("getQuote.av", api.key = "abc") > default.key <- getDefaults("getQuote.av")[["api.key"]] > stopifnot(identical("'abc'", default.key)) > # unset > unset <- unsetDefaults("getQuote.av", confirm = FALSE) > stopifnot(!is.null(unset)) # should not be NULL > default.key <- getDefaults("getQuote.av")[["api.key"]] > stopifnot(is.null(default.key)) > > ## default argument as symbol > # set > setDefaults("getQuote.av", api.key = api.key) > default.key <- getDefaults("getQuote.av")[["api.key"]] > stopifnot(identical(sQuote(api.key), default.key)) > # unset > unset <- unsetDefaults("getQuote.av", confirm = FALSE) > stopifnot(!is.null(unset)) # should not be NULL > default.key <- getDefaults("getQuote.av")[["api.key"]] > stopifnot(is.null(default.key)) > > ### function name as symbol > ### ----------------------- > > ## default argument as character > # set > setDefaults(getQuote.av, api.key = "abc") > default.key <- getDefaults(getQuote.av)[["api.key"]] > stopifnot(identical("'abc'", default.key)) > # unset > unset <- unsetDefaults(getQuote.av, confirm = FALSE) > stopifnot(!is.null(unset)) # should not be NULL > default.key <- getDefaults(getQuote.av)[["api.key"]] > stopifnot(is.null(default.key)) > > ## default argument as symbol > fake.key <- "abc" > # set > setDefaults(getQuote.av, api.key = fake.key) > default.key <- getDefaults(getQuote.av)[["api.key"]] > stopifnot(identical(sQuote(fake.key), default.key)) > # unset > unset <- unsetDefaults(getQuote.av, confirm = FALSE) > stopifnot(!is.null(unset)) # should not be NULL > default.key <- getDefaults(getQuote.av)[["api.key"]] > stopifnot(is.null(default.key)) > > # }}} Unexported function > > > # {{{ Exported function > > ### function name as character > ### -------------------------- > > ## default argument as character > # set > setDefaults("getSymbols", src = "xyz") > default.src <- getDefaults("getSymbols")[["src"]] > stopifnot(identical("'xyz'", default.src)) > # unset > unset <- unsetDefaults("getSymbols", confirm = FALSE) > stopifnot(!is.null(unset)) # should not be NULL > default.src <- getDefaults("getSymbols")[["src"]] > stopifnot(is.null(default.src)) > > ## default argument as symbol > # set > setDefaults("getSymbols", src = src) > default.src <- getDefaults("getSymbols")[["src"]] > stopifnot(identical("'xyz'", default.src)) > # unset > unset <- unsetDefaults("getSymbols", confirm = FALSE) > stopifnot(!is.null(unset)) # should not be NULL > default.src <- getDefaults("getSymbols")[["src"]] > stopifnot(is.null(default.src)) > > ### function name as symbol > ### ----------------------- > > ## default argument as character > # set > setDefaults(getSymbols, src = "xyz") > default.src <- getDefaults(getSymbols)[["src"]] > stopifnot(identical("'xyz'", default.src)) > # unset > unset <- unsetDefaults(getSymbols, confirm = FALSE) > stopifnot(!is.null(unset)) # should not be NULL > default.src <- getDefaults(getSymbols)[["src"]] > stopifnot(is.null(default.src)) > > ## default argument as symbol > # set > setDefaults(getSymbols, src = src) > default.src <- getDefaults(getSymbols)[["src"]] > stopifnot(identical("'xyz'", default.src)) > # unset > unset <- unsetDefaults(getSymbols, confirm = FALSE) > stopifnot(!is.null(unset)) # should not be NULL > default.src <- getDefaults(getSymbols)[["src"]] > stopifnot(is.null(default.src)) > > # }}} Exported function > > proc.time() user system elapsed 0.28 0.04 0.32