str_englue {forstringr} | R Documentation |
Dynamic plot labels using glue operators
Description
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 |
error_call |
The execution environment of a currently
running function, e.g. |
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
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)
[Package forstringr version 1.0.0 Index]