Learn R Programming

expss (version 0.5.5)

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

Description

In many cases one need to address variables in list/data.frame in 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)]. subst is simple string interpolation function. It searches in its arguments expressions in backticks (`), evaluate it and substitute it with result of evaluation. See examples.

Usage

qc(...)
subst(...)

Arguments

...
characters in subst/unquoted names of variables in qc

Value

Vector of characters

Examples

Run this code

## qc
qc(a, b, c)
identical(qc(a, b, c), c("a", "b", "c"))

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

## subst
i = 1:5
subst("q`i`")

i = 1:3
j = 1:3
subst("q1_`i`_`j`")

data(iris)
subst("'iris' has `nrow(iris)` rows.")

Run the code above in your browser using DataLab