Learn R Programming

expss (version 0.10.7)

qc: Create vector of characters from unquoted strings (variable names)

Description

  • qc It is often needed to address variables in the data.frame in the such manner: dfs[ , c("var1", "var2", "var3")]. qc ("quoted c") is a shortcut for the such cases to reduce keystrokes. With qc you can write: dfs[ , qc(var1, var2, var3)].

  • qe returns list of expression. It is useful to create substitution list for ..$arg.

  • text_expand is simple string interpolation function. It searches in its arguments expressions in curly brackets {expr}, evaluate them and substitute with the result of evaluation. See examples.

Usage

qc(...)

qe(...)

text_expand(..., delim = c("\\{", "\\}"))

Arguments

...

characters in text_expand, unquoted names of variables in qc or unquoted expressions in qe.

delim

character vector of length 2 - pair of opening and closing delimiters for the templating tags. By default it is curly brackets. Note that delim will be used in the perl-style regular expression so you need to escape special characters, e. g. use "\\{" instead of "\{".

Value

Vector of characters

Examples

Run this code
# NOT RUN {
## qc
qc(a, b, c)
identical(qc(a, b, c), c("a", "b", "c"))

mtcars[, qc(am, mpg, gear)]

## text_expand
i = 1:5
text_expand("q{i}")

i = 1:3
j = 1:3
text_expand("q1_{i}_{j}")

data(iris)
text_expand("'iris' has {nrow(iris)} rows.")

## qe
qe(mrset(a1 %to% a6), mrset(b1 %to% b6), mrset(c1 %to% c6))
# }

Run the code above in your browser using DataLab