所以我想使用 && 和/或 || 并重新编程 NthRoot 函数。NthRoot 函数代码是这样的:
NthRoot<-function(m,n) {
if(!is.integer(n)!=1) {
stop("Error: N must have length 1. Go away.")
}
else if (!is.integer(n) | is.numeric(n)) {
return(m^1/n)
}
else
stop('Error: You must input an interger or vector of intergers.
Existing...\n\n')}
当我用 double & 和 double | 替换 if 和 else if 时,我收到一条错误消息,Error: unexpected '&&' in: "NthRoot<-function(m,n) { &&"。我很难理解 R 编程的这一部分,所以我很挣扎。任何帮助是极大的赞赏。谢谢