Running examples in 'anfis-Ex.R' failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: ANFIS-class
> ### Title: ANFIS S4 class implementation in R
> ### Aliases: ANFIS-class
> 
> ### ** Examples
> 
> ##Set 2 cores using global options for parallel library
> require("parallel")
> if(.Platform$OS.type == "windows"){
+  options(mc.cores=1)
+ }else{
+  options(mc.cores=2) ##You could use all calling detectCores()
+ }
> 
> ##Example domain for bidimentional sinc(x,y) function
> x <- seq(-10, 10, length= 11)
> trainingSet <- trainSet(x,x)
> Z <- matrix(trainingSet[,"z"],ncol=length(x),nrow=length(x))
> persp(x,x,Z,theta = 45, phi = 15, expand = 0.8, col = "lightblue",
+  ticktype="detailed",main="sinc(x)*sinc(y)")
> 
> ##Training domain patterns
> X <- trainingSet[,1:2]
> Y <- trainingSet[,3,drop=FALSE]
> 
> ##Defining the required MembershipFunctions for the ANFIS
> membershipFunction<-list(
+  x=c(new(Class="NormalizedGaussianMF",parameters=c(mu=-10,sigma=2)),
+    new(Class="NormalizedGaussianMF",parameters=c(mu=-5,sigma=2)),
+    new(Class="NormalizedGaussianMF",parameters=c(mu=0,sigma=2)),
+    new(Class="NormalizedGaussianMF",parameters=c(mu=5,sigma=2)),
+    new(Class="NormalizedGaussianMF",parameters=c(mu=10,sigma=2))),
+  y=c(new(Class="NormalizedGaussianMF",parameters=c(mu=-10,sigma=2)),
+    new(Class="NormalizedGaussianMF",parameters=c(mu=-5,sigma=2)),
+    new(Class="NormalizedGaussianMF",parameters=c(mu=0,sigma=2)),
+    new(Class="NormalizedGaussianMF",parameters=c(mu=5,sigma=2)),
+    new(Class="NormalizedGaussianMF",parameters=c(mu=10,sigma=2))))
> 
> ##Creating the ANFIS network with 2 inputs and 4 MembershipFunctions in
> ##each input
> anfis3 <- new(Class="ANFIS",X,Y,membershipFunction)
> anfis3
ANFIS network 
Trainning Set: 
	 dim(x)= 121x2 
	 dim(y)= 121x1 
Arquitecture:  2 ( 5x5 ) - 25 - 75 ( 75x1 ) - 1 
Network not trained yet 
> 
> ##Check for epsilon-completeness in each input
> plotMFs(anfis3)
> 
> ##Training the ANFIS network.
> ##We will use instead an already trained object to reduce example time.
> data(anfis3)
> 
> ##How the training went. You can keep on training as the training error
> ##is still descending.
> plot(anfis3)
> 
> ##Test the fit, i. e., how the MembershipFunctions partition the input space
> plotMFs(anfis3)
> 
> ##Just to see if premises, consequents and errors were updated
> getPremises(anfis3)[[input=1]][[mf=1]]
MembershipFunction:  Normalized Gaussian Membership Function 
Number of parameters: 2 
       mu     sigma 
-9.984987  2.038630 
Expression: expression(exp(-1/2 * ((x - mu)/sigma)^2))
> getConsequents(anfis3)[1:2,]
[1] 0.005011691 0.005011691
> getErrors(anfis3) #Training errors
 [1] 0.03741022 0.03238312 0.02992609 0.02866609 0.02759035 0.02661405
 [7] 0.02569998 0.02482807 0.02398628 0.02316705 0.02271256 0.02224352
[13] 0.02176043 0.02126397 0.02075495 0.02023433 0.01970327 0.01916307
> getTrainingType(anfis3)
[1] "trainHybridJangOffLine"
> names(coef(anfis3))
[1] "premises"    "consequents"
> ##An alternative to get premises and/or consequents ...
> coef(anfis3)$premises[[input=1]][[mf=1]]
MembershipFunction:  Normalized Gaussian Membership Function 
Number of parameters: 2 
       mu     sigma 
-9.984987  2.038630 
Expression: expression(exp(-1/2 * ((x - mu)/sigma)^2))
> coef(anfis3)$consequents[1:2,]
[1] 0.005011691 0.005011691
> 
> ##First five train pattern associated values for the training process
> fitted(anfis3)[1:5,]
[1] -0.008394804  0.007514315  0.012824644 -0.003044622 -0.030125619
> resid(anfis3)[1:5,]
[1]  0.011354394 -0.014242212 -0.010291178  0.013337535  0.005391769
> summary(anfis3)
ANFIS network 
Trainning Set: 
	 dim(x)= 121x2 
	 dim(y)= 121x1 
Arquitecture:  2 ( 5x5 ) - 25 - 75 ( 75x1 ) - 1 
Last training error:  0.01916307 

Call: trainHybridJangOffLine(object = anfis3, epochs = 10)

Statistics for Off-line training
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
0.01916 0.02139 0.02358 0.02489 0.02735 0.03741 
> 
> ##Surface comparison between the original training set and the predicted
> ##ANFIS network
> y <- predict(anfis3,X)
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
anfis
 --- call from context --- 
FUN(X[[i]], ...)
 --- call from argument --- 
if (class(tita_1) == "list") {
    aux <- matrix(NA, nrow = max(sapply(tita_1, length)), ncol = ncol(x))
    invisible(sapply(seq(along = tita_1), function(input) {
        aux[1:length(tita_1[[input]]), input] <<- tita_1[[input]]
        return(NULL)
    }))
    tita_1 <- aux
}
 --- R stacktrace ---
where 1: FUN(X[[i]], ...)
where 2: lapply(1:nrow(x), function(pattern) {
    tita_1 <- sapply(seq(along = object@premises), function(input, 
        pattern) {
        unlist(lapply(object@premises[[input]], function(MF) {
            evaluateMF(MF, x[pattern, input])
        }))
    }, pattern)
    if (class(tita_1) == "list") {
        aux <- matrix(NA, nrow = max(sapply(tita_1, length)), 
            ncol = ncol(x))
        invisible(sapply(seq(along = tita_1), function(input) {
            aux[1:length(tita_1[[input]]), input] <<- tita_1[[input]]
            return(NULL)
        }))
        tita_1 <- aux
    }
    if (!is.matrix(tita_1)) {
        tita_1 <- t(tita_1)
    }
    w <<- cbind(w, apply(object@rules, 1, function(rule, tita_1) {
        prod(sapply(seq(along = rule), function(input, tita_1) {
            tita_1[rule[input], input]
        }, tita_1))
    }, tita_1))
    wSum <<- c(wSum, sum(w[, pattern]))
    wNormalized <<- cbind(wNormalized, w[, pattern]/wSum[pattern])
    A <<- rbind(A, matrix(matrix(c(x[pattern, ], 1), ncol = 1) %*% 
        wNormalized[, pattern], nrow = 1, byrow = FALSE))
    return(NULL)
})
where 3: .local(object, ...)
where 4: predict(anfis3, X)
where 5: predict(anfis3, X)

 --- value of length: 2 type: logical ---
[1] FALSE FALSE
 --- function from context --- 
function (pattern) 
{
    tita_1 <- sapply(seq(along = object@premises), function(input, 
        pattern) {
        unlist(lapply(object@premises[[input]], function(MF) {
            evaluateMF(MF, x[pattern, input])
        }))
    }, pattern)
    if (class(tita_1) == "list") {
        aux <- matrix(NA, nrow = max(sapply(tita_1, length)), 
            ncol = ncol(x))
        invisible(sapply(seq(along = tita_1), function(input) {
            aux[1:length(tita_1[[input]]), input] <<- tita_1[[input]]
            return(NULL)
        }))
        tita_1 <- aux
    }
    if (!is.matrix(tita_1)) {
        tita_1 <- t(tita_1)
    }
    w <<- cbind(w, apply(object@rules, 1, function(rule, tita_1) {
        prod(sapply(seq(along = rule), function(input, tita_1) {
            tita_1[rule[input], input]
        }, tita_1))
    }, tita_1))
    wSum <<- c(wSum, sum(w[, pattern]))
    wNormalized <<- cbind(wNormalized, w[, pattern]/wSum[pattern])
    A <<- rbind(A, matrix(matrix(c(x[pattern, ], 1), ncol = 1) %*% 
        wNormalized[, pattern], nrow = 1, byrow = FALSE))
    return(NULL)
}
<environment: 0x3d23890>
 --- function search by body ---
 ----------- END OF FAILURE REPORT -------------- 
Fatal error: the condition has length > 1