Skip to main content

Posts

Showing posts from September, 2024

Week 5: Matrix Operations and a bit of Data Manipulation

  Week 5: Matrix Operations and a bit of Data Manipulation  Objective This week’s assignment focused on matrix operations, specifically finding the inverse and determinant of matrices. Additionally, I explored some data manipulation techniques, which I will summarize below. Part 1: Matrix Operations Matrix Creation I created two matrices: Matrix A : A 10x10 matrix containing values from 1 to 100. Matrix B : A 10x100 matrix containing values from 1 to 1000. Determinant and Inverse of Matrix A The   determinant   of   Matrix A   was found to be   0 , indicating that it is   singular   and does not have an inverse. Matrix B   is non-square (10x100), so it cannot have a determinant or an inverse. Error Handling When attempting to compute the inverse of   Matrix A   using the   solve()   function, R returned an error indicating that the matrix is singular. This message means that the matrix does not have an inverse because...

Week 4: Analyzing Patient Blood Pressure and Medical Ratings

 Week 4: Analyzing Patient Blood Pressure and Medical Ratings In this week’s assignment, I worked with a dataset collected by a local hospital that includes various observations from eight patients. The data consists of five variables: frequency of hospital visits (Freq), blood pressure measurements (bloodp), first assessment by a general doctor (visit_1), second assessment by an external doctor (visit_2), and the final decision regarding immediate care (visit_3). Data Overview The dataset features a mix of patient blood pressure readings and medical assessments. The "first" and "second" columns indicate the ratings from the doctors (with "bad" coded as 1 and "good" as 0), while the "finaldecision" column reflects the emergency unit’s decision on the patients' care (low = 0, high = 1). Data Visualization I created a side-by-side boxplot and a histogram to visualize the blood pressure data. The histogram illustrates the distribution ...

Week 3 Blog: Playing with DataFrames—Correcting Errors and Analyzing Fictional Poll Results

  Week 3 Blog: Playing with DataFrames—Correcting Errors and Analyzing Fictional Poll Results Introduction This week's assignment involved working with a fictional dataset representing poll results from the 2016 U.S. Presidential election. The dataset included seven candidates and their results from two polling sources: ABC and CBS. However, before diving into the analysis, I encountered a few errors in the initial dataset that I had to correct. Initial Errors and Corrections The data I was provided had some formatting issues that needed fixing before I could proceed. For example: Quotation Marks:   Some of the names had incorrect quotation marks ( “ ”   instead of   " ), which R couldn’t recognize. I fixed this by replacing all smart quotes with regular quotation marks ( " ). Commas:   The ABC and CBS poll results had some missing commas. Without proper separation, R would misinterpret the values. I inserted the missing commas to correctly format the vectors. H...

Week 2: Fixing the myMean Function and Understanding Flexibility in Function Inputs

  Week 2: Fixing the   myMean   Function and Understanding Flexibility in Function Inputs Introduction This week, my assignment involved evaluating and debugging a custom function called   myMean , which calculates the mean (average) of a dataset. While the concept behind the function was simple, there were a couple of key issues with the inputs that prevented it from working correctly. Here's a walkthrough of the problem, how I approached it, and the final solution. The Problem The original function I was asked to evaluate was defined as follows: The dataset provided to test this function was: At first glance, the function seemed like it should calculate the sum of the vector and divide it by the number of elements. However, there were two key issues: Incorrect Input in   sum() : The function was using   sum(assignment) , which referenced a variable not passed into the function. Incorrect Input in   length() : The function referenced   length(som...