我希望在闪亮的情节中使用Shiny输入作为名称 .
这是我的代码:
ggplot() +
...
geom_point(data=data.frame(), aes(x=x, y=y, color=paste(input$name)),
size = 3) +
scale_color_manual(values=c("df1"="blue", "df2"="blue",
paste(input$name)="red"))
它不会将 paste(input$name)
识别为字符串 . 这是错误消息:
1512: scale_color_manual(values=c("df1"="blue", "df2"="blue",
1513: paste(input$name)=
^
有谁知道如何正确构建这个?
1 回答
你不能像你一样混合字符串,符号和表达式 . 如果要在
aes()
映射中使用字符串,请使用aes_
或aes_string
(不需要paste
)而且你不能在一个命名向量中的
=
左侧放置一个表达式 . 请改用setNames()
之类的东西 .如上所述,如果您包含reproducible example将来会更容易,以便可以正确测试可能的解决方案 . 这根本不是Shiny相关的 . 这就是
ggplot
和R的工作原理 .