问题描述
我有两个功能:
exclude <- function(df,...) {
dots <- rlang::enquos(...)
for(i in 1:length(dots)) {
df <- exclude_cycle(df,dots[[i]])
}
return(df)
}
exclude_cycle <- function(df,condition) {
df <- dplyr::filter(df,!!condition)
print(paste(nrow(df),"records left after excluding",eval(condition),sep = " "))
return(df)
}
我希望print(paste(nrow(df),sep = " "))
打印一个看起来像100000 records left after excluded age > 18
的简单字符串,其中age > 18
是我直接传递给exclude
函数的过滤器:
exclude(df,age > 18)
我最终得到的输出类似于:
[1] "100000 records left after excluding ~" "100000 patients left after excluding age >= 18"
这与我想要的非常接近,但是每个字符向量打印两个字符串而不是1。如何获得所需的输出?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)