Posts

Showing posts from November, 2023

Week 12: R Markdown

Hi everyone! This week we learned about R Markdowns which are interactive R documents to nicely format text and r code to present to viewers. In my R Markdown, I started developing the code for my final project R package: hireLetter.  Check this out in GitHub ! Reflection: I found developing an R Markdown file very user-friendly and simple. I enjoyed writing headings and descriptive text outside of the code instead of entirely using comments as we did in R scripts. After starting to write the code for my final project, I was faced with many challenges. I utilized my knowledge of shiny apps from a previous class to begin my code because I realized user input is very important for my package and shiny app gives a great format for this. I hope to further develop my shiny app function after learning more in the next module of this course. I have a few issues and questions I would appreciate help resolving.  How can I  reference the pass and fail output tab...

Week 11: Debugging and defensive programming

Image
Hi everyone! This week we learned about debugging in R. Debugging involves fixing the issues as they arise in the code you write. In R, there is an in-built debugging function in the Debug tab that toggles breakpoints. To take a more code based debugging approach, we can use traceback(), debug(), or trace() to see line by line where the error lies. 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! The first step I took to understand where the bug may be was to simply run the code in R to see the error message which is seen below. This message says there is an...