The qc() function is intended to help quote user inputs.

qc(..., .wrapr_private_var_env = parent.frame())

Arguments

...

items to place into an array

.wrapr_private_var_env

environment to evaluate in

Value

quoted array of character items

Details

qc() a convenience function allowing the user to elide excess quotation marks. It quotes its arguments instead of evaluating them, except in the case of a nested call to qc() or c(). Please see the examples for typical uses both for named and un-named character vectors.

qc() uses bquote() .() quasiquotation escaping notation. Also take care: argumetns are parsed by R before being passed to qc(). This means 01 is interpreted as 1 and a string such as 0z1 is a syntax error. Some notes on this can be found here: https://github.com/WinVector/wrapr/issues/15#issuecomment-962092462

See also

Examples

a <- "x" qc(a) # returns the string "a" (not "x")
#> [1] "a"
qc(.(a)) # returns the string "x" (not "a")
#> [1] "x"
qc(.(a) := a) # returns c("x" = "a")
#> x #> "a"
qc("a") # return the string "a" (not "\"a\"")
#> [1] "a"
qc(sin(x)) # returns the string "sin(x)"
#> [1] "sin(x)"
qc(a, qc(b, c)) # returns c("a", "b", "c")
#> [1] "a" "b" "c"
qc(a, c("b", "c")) # returns c("a", "b", "c")
#> [1] "a" "b" "c"
qc(x=a, qc(y=b, z=c)) # returns c(x="a", y="b", z="c")
#> x y z #> "a" "b" "c"
qc('x'='a', wrapr::qc('y'='b', 'z'='c')) # returns c(x="a", y="b", z="c")
#> x y z #> "a" "b" "c"
c(a = c(a="1", b="2")) # returns c(a.a = "1", a.b = "2")
#> a.a a.b #> "1" "2"
qc(a = c(a=1, b=2)) # returns c(a.a = "1", a.b = "2")
#> a.a a.b #> "1" "2"
qc(a := c(a=1, b=2)) # returns c(a.a = "1", a.b = "2")
#> a.a a.b #> "1" "2"