Posts

Showing posts from September, 2025

Module 5. Assignment- inspecting matrices in R

Image
  (Please select image for better clarity) Why  solve(A)  and  det(A)  work. For matrix A, det(A) gives an output of zero. That’s because of how A <- matrix(1:100, nrow=10) is filled: the columns are simple combinations of the vectors of all 1s and 1:10, so the matrix doesn’t have full rank. A zero determinant means A is singular, which means there’s no true inverse. That’s why solve(A) would normally error out. It works in the script because it is wrapped with tryCatch to catch the error.  Why operations on B fail (non‑square matrix). Matrix B it’s 10×100, not square which is simply why it failed. Both solve() and det() need a square matrix. So the unwrapped calls would error by definition (as seen), and with tryCatch it captures those errors and continues with the computation.  Any notes on numeric stability or performance. I keep it simple: first I check dim() to make sure the matrix is square. Then I wrap the risky parts—solve() and det()—with t...

Module 4- Boxplots and Histograms

Image
The following presents the boxplots and histograms created by the code:      The boxplots revealed that blood pressure values differ meaningfully across assessments. In the first MD assessment, patients rated as “Bad” tend to have higher median blood pressures than those rated as “Good,” which supports the expectation that elevated BP is associated with worse evaluations. Similarly, in the second MD assessment, those labeled “High” have a noticeably wider range of blood pressure values, including extreme values, while the “Low” group is more tightly clustered around lower readings. Finally, in the final decision, the “High” category clearly corresponds to higher blood pressures compared to the “Low” group, reinforcing the consistency between clinical assessments and the ultimate classification. There are some patterns that could be observed from the dataset. First, the histogram of blood pressure shows a wide spread, with values ranging from the low 30s to just above 200....

Module 3 Assignment- Summary Statistics and Visualization of Categorical Data

Image
When looking at the ABC and CBS poll numbers, a few patterns are noticeable. Some candidates are fairly close between the two polls, while others show significant differences. For example, Donald’s support is much higher in the CBS poll than in the ABC poll, with a gap of more than 10 points. Hillary also shows a noticeable increase in the CBS poll compared to the ABC poll. On the other hand, Ted and Marco actually score lower in the CBS poll, which shows how results can shift depending on the source. The CBS poll also has a wider range (1 to 75) than ABC (2 to 62). That suggests CBS shows bigger extremes—pushing some candidates higher and some lower. Utilizing the difference chart, Jeb (+8) and Bernie (+4) have differences, but they’re not as dramatic as Donald (13).  Some candidates have very low differences, notably Carly (-1) and Marco (-2).  The impact of using superficial, or made-up data is that the findings cannot be applied to real-world scenarios. In this c...

Module 2. Assignment: Function Debugging and Evaluation in R

Image
 Assignment Instructions: The initial test results can be found below and included the following error message: "Error in myMean(assignment2) : object 'assignment' not found".  The reason why this function failed is because assignment and someData are undefined variable names. R cannot identify their function and they are not existing objects in the environment, and as a result produces an error message.  Now, a corrected version of myMean that correctly returns the mean of assignment2 will be computed.  The mean is  19.07692. In this iteration, we changed the parameters to include 'data' and both sum(data) and length(data) use the same parameter. Consistent variable names are important in R programming to ensure data integrity and cohesion!