I would like to generate a hovertext for ggplotly()
using aes()
along the lines of
mapping <- aes(text = paste0(
"Value: ",
columnName
))
where columnName
is a variable containing a column name as a string. Now, I don't want columnName
recognized as a column name itself. If columnName == "col1"
the result I want is
aes(text = paste0(
"Value: ",
col1
))
which evaluates to the aesthetic mapping `text` -> `paste0("Value: ", col1)`
.
I have tried using aes_string()
, but
columnName <- "col1"
aes_string(text = paste0(
"Value: ",
columnName
))
just evaluates to the aesthetic mapping `x` -> `Value:col1`
.
How do I make this work?