qqcat: Print a string which has been intepolated with variables

Description Usage Arguments Details Author(s) Examples

View source: R/qq.R

Description

Print a string which has been intepolated with variables

Usage

1
2
3
qqcat(..., envir = parent.frame(), code.pattern = NULL, file = "",
    sep = " ", fill = FALSE, labels = NULL, append = FALSE, cat_prefix = NULL,
    strwrap = qq.options("cat_strwrap"), strwrap_param = list(), sep2 = "")

Arguments

...

text string in which variables are marked with certain rules

envir

environment where to look for those variables

code.pattern

pattern of marks for the variables

file

pass to cat

sep

pass to cat

fill

pass to cat

labels

pass to cat

append

pass to cat

cat_prefix

prefix string. It is prior than qq.options(cat_prefix).

strwrap

whether call strwrap to wrap the string

strwrap_param

parameters sent to strwrap, must be a list

sep2

Separation character when there are multiple templates.

Details

This function is a shortcut of

1
    cat(qq(text, envir, code.pattern), ...)  

Additionally, you can add global prefix:

1
2
3
    qq.options("cat_prefix" = "[INFO] ")
    qq.options("cat_prefix" = function(x) format(Sys.time(), "[%Y-%m-%d %H:%M:%S] "))
    qq.options("cat_prefix" = NULL)  

You can also add local prefix by specifying cat_prefix in qqcat.

1
    qqcat(text, cat_prefix = "[INFO] ")  

Please refer to qq to find more details.

Author(s)

Zuguang Gu <z.gu@dkfz.de>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
a = 1
b = "text"
qqcat("a = @{a}, b = '@{b}'\n")
qqcat("a = `a`, b = '`b`'\n", code.pattern = "`CODE`")

qq.options("cat_prefix" = function(x) format(Sys.time(), "[%Y-%m-%d %H:%M:%S] "))
qqcat("a = @{a}, b = '@{b}'\n")
Sys.sleep(2)
qqcat("a = @{a}, b = '@{b}'\n")
qq.options(RESET = TRUE)

GetoptLong documentation built on Jan. 8, 2021, 2:29 a.m.