Posts

Showing posts from April, 2026

Assignment 12

Image
For this assignment, I learned that R Markdown is a useful tool for combining writing, code, and math in one document. I practiced using Markdown syntax to create headings and paragraphs, and I also learned how to include LaTeX math expressions both inline and as displayed equations. This helped me understand how R Markdown can take a simple source file and turn it into a clean, professional-looking report. I also learned how code chunks and narrative sections work together in R Markdown. The code chunks allow analysis and plots to be generated directly in the document, which makes everything more organized and reduces errors from copying results manually. One challenge I faced was making sure the formatting was correct, especially with code chunks and symbols, because small mistakes can stop the document from knitting. Overall, this assignment showed me how R Markdown supports reproducible analysis and is more efficient than writing plain reports. r-programming-assignments/README.md ...

Assignment 11

Image
For this assignment, I debugged a function that was supposed to identify rows in a numeric matrix where every column is flagged as a Tukey outlier. When I tested the original function on a sample matrix, I got this error: Error in outliers[, j] && tukey.outlier(x[, j]) : 'length = 10' in coercion to 'logical(1)' . This happened because the function used && inside the loop. In R, && is not vectorized, so it only checks the first value of each logical vector instead of comparing all elements. Since outliers[, j] and tukey.outlier(x[, j]) are both logical vectors of length 10, using && caused R to try forcing that full vector into a single logical value. I fixed the bug by replacing && with & , which performs element-wise logical comparison across the whole vector. After that change, the corrected function ran successfully and returned a logical vector of length 10 with no error. I also added defensive programming checks t...