Module 11 Assignment

 Module 11 Assignment

Identify the bug in example code:

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) }

My first step was to run the code to test the function. I received this error:

This helped me narrow down my search of the bug to the second for loop in the function. I wanted to run debug on the function, however, I learned I have to load the function into my local environment first. I changed the working directory to where the file is located on my device and tried to source the R file as shown below. 

However, sourcing the R file did not work because the file has an error in it, so the function still does not exist in my environment. I tried running the code line by line but it did not reveal to me what the issue could be. 

I tried to load the file into the global environment in RStudio manually but received this error message shown below. 


At this point, I am not sure how to use debug on this file since I cannot figure out how to load the function into my environment and why it will not load. Any guidance at this point would be appreciated.





Comments

Popular posts from this blog

Module 10 Assignment

Module 1 Assignment