Module # 11 Debugging and defensive programming in R
The code below contains a 'deliberate' bug! 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) } > Find the bug and fix it . >> Report on your blog the success or failure in your debugging procedure. After inputting the code into Rstudio, i get the result: Error: unexpected symbol in: " for (i in 1:nrow(x)) { outlier.vec[i] <- all(outliers[i,]) } return" After careful examination I noticed two issues. First, the structure of the function was not aligned properly. This had to be modified in order for Rstudio to recognize the function. Second, there appears to be &&. &...