existsAnywhereOption-character-ANY-method: Check Existence of an Anywhere Option (char-any)

Description Usage Arguments Value Author(s) References See Also Examples

Description

See generic: existsAnywhereOption

Usage

1
2
3
4
## S4 method for signature 'character,ANY'
existsAnywhereOption(id,
  where = tryCatch(devtools::as.package(".")$package, error = function(cond) {
      stop("Invalid default value for `where`") }), strict = c(0, 1, 2), ...)

Arguments

id

character.

where

ANY.

strict

logical. Controls what happens when id points to a non-existing option object:

  • 0: ignore and return FALSE to signal that the assignment process was not successful or fail_value depending on the value of return_status

  • 1: ignore and with warning and return FALSE

  • 2: ignore and with error

...

Further arguments to be passed to subsequent functions/methods.

Value

See method existsAnywhereOption-char-env-method

Author(s)

Janko Thyson janko.thyson@gmail.com

References

http://github.com/Rappster/optionr

See Also

existsAnywhereOption

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
## Not run: 

##------------------------------------------------------------------------------
## Basics //
##------------------------------------------------------------------------------

setAnywhereOption(id = "test", value = TRUE)
existsAnywhereOption(id = "test")

setAnywhereOption(id = "a/b/c", value = 10)
existsAnywhereOption(id = "a")
existsAnywhereOption(id = "a/b")
existsAnywhereOption(id = "a/b/c")
existsAnywhereOption(id = "a/b/c/d")

existsAnywhereOption(id = "c")
existsAnywhereOption(id = "c/d/e")
  
##------------------------------------------------------------------------------
## Strictness levels //
##------------------------------------------------------------------------------

## Empty ID //
existsAnywhereOption(id = character())
try(existsAnywhereOption(id = character(), strict = 1))
try(existsAnywhereOption(id = character(), strict = 2))

## Not-existing //  
existsAnywhereOption(id = "c/d/e")
try(existsAnywhereOption(id = "c/d/e", strict = 1))
try(existsAnywhereOption(id = "c/d/e", strict = 2))

##------------------------------------------------------------------------------
## Explicit `where` //
##------------------------------------------------------------------------------

where <- new.env()
setAnywhereOption(id = "a/b/c", value = 10, where = where)
existsAnywhereOption(id = "a/b/c", where = where)
existsAnywhereOption(id = "a/b/c/d", where = where)
existsAnywhereOption(id = "c/d/e", where = where)


## End(Not run)

rappster/optionr documentation built on May 26, 2019, 11:23 p.m.