call_concatenate {teal.modules.clinical}R Documentation

Concatenate expressions via a binary operator

Description

e.g. combine with + for ggplot without introducing parentheses due to associativity

Usage

call_concatenate(args, bin_op = "+")

Arguments

args

arguments to concatenate with operator

bin_op

binary operator to concatenate it with

Value

a call

Examples

library(ggplot2)

# What we want to achieve
call("+", quote(f), quote(g))
call("+", quote(f), call("+", quote(g), quote(h))) # parentheses not wanted
call("+", call("+", quote(f), quote(g)), quote(h)) # as expected without unnecessary parentheses
Reduce(function(existing, new) call("+", existing, new), list(quote(f), quote(g), quote(h)))

# how we do it
call_concatenate(list(quote(f), quote(g), quote(h)))
call_concatenate(list(quote(f)))
call_concatenate(list())
call_concatenate(
  list(quote(ggplot(mtcars)), quote(geom_point(aes(wt, mpg))))
)

eval(
  call_concatenate(
    list(quote(ggplot(mtcars)), quote(geom_point(aes(wt, mpg))))
  )
)


[Package teal.modules.clinical version 0.9.1 Index]