首页 > 解决方案 > R 防止 Lazyeval

问题描述

我想high()rPref库中使用更改变量名,例如

df <- data.frame(x = c(1,2,3), y = c(2,3,0))
psel(df, high(x) * high(y))

但是如果我事先不知道列名,我试过这个

psel(df, Reduce("*", sapply(colnames(df), high)))

这使

Error in calc_scores(object, df, frm) : 
  For the high preference high(X[[i]]) the expression must be numeric!

我试过force()了,但在这里没有帮助

编辑:没关系,我意识到rPref也有high_()标准评估..

标签: rlazy-evaluation

解决方案


推荐阅读