首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在回忆录中传递带有参数的函数

如何在回忆录中传递带有参数的函数
EN

Stack Overflow用户
提问于 2022-03-21 06:42:31
回答 1查看 35关注 0票数 0

当试图在memosie中传递函数时,我得到了一个Error in FUN(X[[i]], ...) : object 'condition' not found错误,但是如果单独运行,它就可以正常工作了。

这是示例函数,实际上在我闪亮的应用程序中,我也得到了相同的错误

代码语言:javascript
复制
library(ggplot2)

meansdf <- data.frame(means = c(13.8, 14.8), condition = 1:2)

testplot <- function(df, x, y) {
  arg <- match.call()
  scale <- 0.5
  p <- ggplot(df, aes(x = eval(arg$x),
                      y = eval(arg$y) * scale,
                      fill = eval(arg$x)))
  p + geom_bar(position = "dodge", stat = "identity")
}

a = memoise::memoise(testplot)

a(meansdf, condition, means)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-03-21 07:02:34

使用,

代码语言:javascript
复制
a(meansdf, meansdf$condition, meansdf$means)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71553677

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档