vcat: cat function with built in verbosity

Description Usage Arguments Details See Also Examples

View source: R/helper_functions.R

Description

Depending on the parent frame's "verbose" logical object state (T/F), cat R object(s).

Usage

1
vcat(..., sep = " ", bypass = FALSE)

Arguments

...

Things to cat

sep

a character string to separate each element.

bypass

logical. If bypass == T print regardless of other factors.

Details

Outputs the objects, concatenating the representations. cat performs much less conversion than print.

See Also

vprint

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
## Not run: 
dog <- ("dog")

# With no verbose object in the env, and bypass not true, vcat does nothing
vcat(dog)

# Dummy function with verbose as an argument to show "local" environment interactions
foo <- function(verbose = FALSE){
  vcat(dog)
}

# Create a global variable verbose set to TRUE
verbose <-  T
# vcat and foo() now both print the dog object, even though foo's local verbose variable is false. 
# i.e. a global verbose veriable will take precedence over a local one
vcat(dog)
foo(verbose = FALSE)

# With the global verbose object set to FALSE, a direct vcat call does nothing, and if the foo function
# is given TRUE for it's local verbose object, then the 'dog' object is still not printed. As above, 
the global variable takes precedence.
verbose <- F
vcat(dog)
foo()
foo(verbose = TRUE)

# However if there is no global verbose variable, a local variable will cause it to print
rm(verbose)
foo(verbose = TRUE) 

## End(Not run)

MjStansfi/TPDdecomp documentation built on July 20, 2020, 11:51 a.m.