【发布时间】:2016-08-04 00:43:34
【问题描述】:
所以我之前曾多次看到这个问题,但我尝试过的其他答案似乎都不起作用。当我运行以下函数时,我得到:“错误:找不到对象'x'。”
xpermntotable <- function(x,y,z){
xmovematrix <- matrix(unlist(xpermn), ncol = 3, byrow = TRUE)
for(i in 1:120){
xmove1 <- xmovematrix[i,1]
xmove2 <- xmovematrix[i,2]
xmove3 <- xmovematrix[i,3]
print(x)
xtemp <- filter_(fullTable, .dots=list(
bquote(.(as.name(xmove1)) == x),
bquote(.(as.name(xmove2)) == y),
bquote(.(as.name(xmove3)) == z)))
xwin <- rbind(xwin, xtemp)
}
}
xpermntotable(1,2,3)
问题似乎根源于下面函数的特定部分,其中“x”(可能是“y”和“z”)没有被正确读取:
xtemp <- filter_(fullTable, .dots=list(
bquote(.(as.name(xmove1)) == x),
bquote(.(as.name(xmove2)) == y),
bquote(.(as.name(xmove3)) == z)))
我尝试过的解决方案:
- 在 as.name(x) 或 eval(x) 中包含“x”变量
【问题讨论】:
标签: r function user-defined-functions