Posts

Showing posts from September, 2025

Assignment #5: Matrix Algebra in R

Image
  R code for creating A and B, and for computing  invA ,   detA ,   invB , and   detB : Outputs for each operation: Why  solve(A)  and  det(A)  behave this way: Since Matrix A is 10x10 and therefore a square, it could technically have an inverse. However, since the determinant of A is 0, it is considered a singular matrix, meaning it does not have full rank and therefore cannot be inverted. Due to this,  solve(A)   returns an error even though the matrix is a square, yet it is still able to run and confirm the singularity. Why operations on B fail (non‑square matrix): Since Matrix B is 10x100, it is not square. Inverses and determinants can only be defined for square matrices, meaning both solve(B) and det(B) return errors. Though it is expected, it highlights how important it is to check matrix dimensions before attempting further operations.  Notes on numeric stability or performance: There are important considerations w...

Assignment #4: Visualizing and Interpreting Hospital Patient Data

Image
Blood Pressure and Assessments Based on the boxplots, the blood pressures seemed to vary quite a bit. In the first MD assessment, the patients marked "Good" had a wide range of values, with an outlier at 205. Those marked "Bad" seemed to cluster towards the lower or moderate values. The second MD assessment showed patients marked "Low" with blood pressures clustered in the lower range, but showed patients marked "High" with a wide range of values. The Final assessment  seemed to properly correlate "High" with higher values and "Low" with lower values, suggesting the first assessment may have been less related to blood pressures and the second assessment moderately related. Histogram Patterns The histogram of visit frequency shows that most patients clustered around visit rates 0.2-0.6 with no extreme outliers. The histogram for blood pressure shows a much larger distribution, with most patients under 120, some outliers above 1...

Assignment #3: Analyzing 2016 data “Poll” Data in R

Image
Based on the provided poll data, I observed the following patterns by calculating the mean, median, range, and difference between CBS and ABC. Firstly, I observed that on average, CBS had a slightly higher mean of 27.14 compared to ABC's 24.14. For overall discrepancies,  Donald had the highest with +13 percentage points, and Ted had the lowest with -8 percentage points. While there are stark leaders in candidates, Jeb and Hilary also demonstrated moderately notable  percentage points. Using made-up data can present several issues, mainly rooted in the fact that you cannot draw a confident conclusion from it. To really determine the public's opinion from poll data, you would need to increase the sample size over a much longer period of time. Additionally, as in all statistical datasets, it is important to also compute a margin of error. Assuming you implement these methods, another important consideration would be to collect data from highly reputable organizations that approp...

Module #2 - Importing Data and Function Evaluation in R

I was able to successfully create my vector using the provided command:   assignment2 <- c(16, 18, 14, 22, 27, 17, 19, 17, 17, 22, 20, 22) Then, I confirmed that it was assigned to the object "assignment2" by typing "assignment2" in the Console to show the numerical values and viewing it under the  Values  of the Environment tab.  After creating and running the function: myMean <- function(assignment2) { return(sum(assignment) / length(someData)) } I encountered the error message "Error in myMean(assignment2) : object 'assignment' not found". This error message indicates that the function failed and needs revision. The variable name 'assignment' does not match the initial object 'assignment2' that was stored. I updated the function (shown below) and ran  myMean(assignment2) myMean <- function(assignment2) { return(sum(assignment2) / length(someData)) } I then encountered the error message "Error in myMean(assignmen...

R vector concepts

An R vector is a data structure that includes an ordered list of elements of the same data type (i.e., numbers, logical values, or characters). Vectors are exceptionally fundamental to data analysis because they serve as building blocks to most other data structures in R. The most crucial feature, vectorized operations, applies functions to whole vectors at once, allowing for easy and efficient data analysis or manipulation.  References: Chapters 1–2 of Ratloff’s The Art of R Programming Chapters 1–2 of Wickham’s  R for Data Science