Hi,

I am running the following loop, but it takes hours to run as n is big. Is there any way "apply" can be used? Thanks.
### Start
    nclass <- dim(data)[[2]] - 1
    z <- matrix(0, ncol = nclass, nrow = nclass)
    n <- dim(data)[[1]]
    x <- c(1:nclass)
# loop starts
for(loop in 1:n) {
        r <- data[loop, 1:nclass]
        classified <- x[r == max(r)]
       
        truth <- data[loop, nclass + 1]
        z[classified, truth] <- z[classified, truth] + 1
    }
# loop ends


             
---------------------------------

	[[alternative HTML version deleted]]

