How could I use variable name in ggbetweenstats? None of these seem to work:
xField='Species'
ggbetweenstats(
data = iris,
x = xField,
y = Sepal.Length,
title = "Distribution of sepal length across Iris species"
)
ggbetweenstats(
data = iris,
x = as.symbol(xField),
y = Sepal.Length,
title = "Distribution of sepal length across Iris species"
)
CodePudding user response:
Using rlang::sym
and the bang-bang-operator (!!
) you could do:
library(ggstatsplot)
xField <- "Species"
ggbetweenstats(
data = iris,
x = !!rlang::sym(xField),
y = Sepal.Length,
title = "Distribution of sepal length across Iris species"
)