'DEBUGGING' in R
The code below contains a 'deliberate' bug that must be rectified. tukey_multiple <- function(x) { outliers <- array(TRUE,dim=dim(x)) for (j in 1:ncol(x)) { outliers[,j] <- outliers[,j] && tukey.outlier(x[,j]) } outlier.vec <- vector(length=nrow(x)) for (i in 1:nrow(x)) { outlier.vec[i] <- all(outliers[i,]) } return(outlier.vec) } When the above code is implemented, it will result in the following error: Error: unexpected symbol in: " for (i in 1:nrow(x)) { outlier.vec[i] <- all(outliers[i,]) } return" The function 'traceback' prints the list of functions that were called before the error occurred. The function 'source', which reads and executes the code, can be used to find the exact location of the error, which will help to rectify the error. So, when the 'source' function is implemented, it gives the location of the error just before ' return' . > traceback("tukey_multipl...