Skip to contents

str_englue() helps you solve the labeling problem during plotting. For example, any value wrapped in { } will be inserted into the string and it can also understands embracing, {{ }}, which automatically inserts a given variable name.

Usage

str_englue(x, env, error_call, error_arg)

Arguments

x

A string to interpolate with glue operators.

env

User environment where the interpolation data lives in case you're wrapping englue() in another function.

error_call

The execution environment of a currently running function, e.g. caller_env(). The function will be mentioned in error messages as the source of the error. See the call argument of abort() for more information.

error_arg

An argument name as a string. This argument will be mentioned in error messages as the input that is at the origin of a problem.

See also

Examples

# \donttest{
library(ggplot2)

histogram_plot <- function(df, var, binwidth) {
   ggplot(df, aes(x = {{ var }})) +
   geom_histogram(binwidth = binwidth) +
   labs(title = str_englue("A histogram of {{var}} with binwidth {binwidth}"))
}

histogram_plot(iris, Sepal.Length, binwidth = 0.1)

# }