Module 11: Debugging and defensive programming.
This week we learned about debugging and ways we can tackle bugs in our code. Our assignment this week is to debug the following function: 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) } There are deliberate bugs included in this code and our goal is to use our debugging tools to find what possible issues may lie in the function. GitHub link: https://github.com/Ant-nguyen/Intro_r_2021/blob/main/Module%2011.R Let us begin! First thing first we should probably look at our function and have an idea of what it does? This is where it gets tricky. There is no comments in the code (# comments) or inherent restrictions on input that give u...