所以我之前已经多次看过这个问题了,但我尝试过的其他答案似乎都没有。当我运行以下函数时,我得到:“错误:未找到对象'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)))
我尝试过的解决方案:
答案 0 :(得分:0)
因此,在深入研究bquote函数后,我意识到我的解决方案始终存在。 x,y和z变量需要用
包装.()
以下代码有效:
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]
xtemp <- filter_(fullTable, .dots=list(
bquote(.(as.name(xmove1)) == .(x)),
bquote(.(as.name(xmove2)) == .(y)),
bquote(.(as.name(xmove3)) == .(z))))
xwin <- rbind(xwin, xtemp)
return(xwin)
}
}
xwin <- xpermntotable(1,2,3)
有关bquote函数here的更多信息。