append_declaration: Append declarations to code block

Description Usage Arguments Value Examples

Description

appends all ellipses or dots arguments to code at specified location, reconstructing code to initialize variables in the code block.

Usage

1
append_declaration(x, ..., after = length(x), dots = list())

Arguments

x

code block to append to

...

a named list of variables to create declarations for. currently only objects of a subset of types get instantiated:

  • reactivevalues (via reactiveValuesToList())

  • atomic

  • numeric

  • character

after

position at which to insert declaration code

dots

alternative passing of ellipses arguments

Value

reconstructed code with declarations inserted

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Not run: 
# for example purposes, we can disable checcking of a running shiny instance
# as a safeguard against calling `reactiveValuesToList` outside of shiny
options(scirptgloss.testmode = TRUE)

code <- quote({
  a <- tolower(a)
  b <- b[[1]]
  c <- tolower(c)
  print(sprintf('this is %s %dst %s', a, b, c))
})

scriptgloss:::append_declaration(as.list(code)[-1], 
    a = 'my', 
    b = list(1,2,3),
    c = 'example', after = 0)
    
options(scirptgloss.testmode = FALSE) # reset to default behavior

## End(Not run)

dgkf/scriptgloss documentation built on June 8, 2019, 8:43 p.m.