r - NA 作为 aes_string 中的输入
问题描述
根据我的代码,当不提供应该在 aes_string 中定义的所有变量时,我也想执行 aes_string 函数。编码:
test <- function(data, x, y, c){
ggplot(data = data, mapping = aes_string(x = x, y = y, colour = c))
}
当我没有任何颜色变量作为输入时,我也希望能够执行它,例如:
test(data, 'x', 'y', NA)
或者
test(data, 'x', 'y', '')
或类似的,但我不知道我可以输入哪个值作为 ggplot 不考虑它的 c。
解决方案
test(data, 'x', 'y', FALSE)
做了这份工作。
推荐阅读
- javascript - 如何在较新版本的 hapi 中执行 reply.continue(data)
- jmeter - JMeter Run - 线程数与日志中的线程数不同
- xml - XSD 1.1:限制元素的整体属性数量
- json - 返回 django 对象及其相关实例为 json
- reactjs - 反应:应该为每个字段创建唯一的 useState 变量吗?
- javascript - JS Accordion - 如何让下面显示的信息占据 2 个框的宽度
- android - Android DJI SDK - 从 Play 商店安装的我的 App Bundle 挂起一个正常运行的应用程序
- elasticsearch - Elasticsearch apm 中识别的服务
- html -
- c# - 无法确定导航属性 EF Core 表示的关系