Posts

Showing posts from September, 2025

Module 5: Matrix Algebra in R

GitHub Link:  r-programming-assignments/Assignment_05.R at main · AustinTCurtis/r-programming-assignments On your blog, include: R code for creating A and B, and for computing  invA ,  detA ,  invB , and  detB . Output or error messages for each operation. A brief explanation: Why  solve(A)  and  det(A)  work. Why operations on B fail (non‑square matrix). Any notes on numeric stability or performance. R Code: > # Create matrices > A <- matrix(1:100, nrow = 10) # 10 x 10 > B <- matrix(1:1000, nrow = 10) # 10 x 100 > > #Inspect Dimension > cat("dim(A): ", paste(dim(A), collapse = " x "), "\n") # expected 10 x 10 dim(A): 10 x 10 > cat("dim(B): ", paste(dim(B), collapse = " x "), "\n") # expected 10 x 100 dim(B): 10 x 100 > > is_square <- function(M) { d <- dim(M); d[1] == d[2] } > cat("Is A square? ", is_square(A), "\n") Is A square? TRUE > cat("Is B ...

Module #4 Visualizing and Interpreting Hospital Patient Data

Image
Github Repository:   r-programming-assignments/Assignment_04.R at main · AustinTCurtis/r-programming-assignments CODE FROM R Studio: > # Define numeric vectors > Frequency <- c(0.6, 0.3, 0.4, 0.4, 0.2, 0.6, 0.3, 0.4, 0.9, 0.2) > BloodPressure <- c(103, 87, 32, 42, 59, 109, 78, 205, 135, 176) > > # Convert categorical strings to numeric codes > # First assessment: bad=1, good=0 > FirstAssess <- c(1, 1, 1, 1, 0, 0, 0, 0, NA, 1) > > # Second assessment: low=0, high=1 > SecondAssess <- c(0, 0, 1, 1, 0, 0, 1, 1, 1, 1) > > # Final decision: low=0, high=1 > FinalDecision <- c(0, 1, 0, 1, 0, 1, 0, 1, 1, 1) > > # Create data frame > df_hosp <- data.frame( + Frequency, BloodPressure, FirstAssess, + SecondAssess, FinalDecision, + stringsAsFactors = FALSE + ) > > # Inspect data > summary(df_hosp) Frequency BloodPressure FirstAssess SecondAssess FinalDecision Min. :0.20 Min. : 32.0...

Module #3 Analyzing 2016 data “Poll” Data in R

Image
GITHUB Repository:  r-programming-assignments/Assignment_03.R at main · AustinTCurtis/r-programming-assignments On your blog, write 2–3 paragraphs addressing: Key patterns you observe (e.g., which candidate shows the largest discrepancies). Impact of using made‑up data—what limitations does this introduce? How you might collect or validate real poll data in a true analysis. Looking at the data, Donald shows very high numbers in both polls, but CBS rates him even higher than ABC, resulting in one of the largest positive differences. On the other hand, Ted has a strong ABC showing (51%) but weaker support in CBS (43%), producing a negative gap. Smaller candidates like Carly and Jeb also show discrepancies, but because their overall numbers are low, the differences are less impactful. The new column Diff makes these gaps clearer at a glance. Since this dataset is fictional, the results can only highlight how differences between polls might appear rather than reflect reality. Made-up n...

Module # 2 Assignment Importing Data and Function Evaluation in R

Image
  Evaluate  myMean  Function Use the vector: assignment2 <- c(16, 18, 14, 22, 27, 17, 19, 17, 17, 22, 20, 22) Consider this function: myMean <- function(assignment2) { return(sum(assignment) / length(someData)) } In RStudio, run  myMean(assignment2)  and record the output or error. After running the code in R Studio this is the error that occurred: > assignment2 <- c(16, 18, 14, 22, 27, 17, 19, 17, 17, 22, 20, 22) > myMean <- function(assignment2) { + return(sum(assignment) / length(someData)) + } > assignment2 <- c(16, 18, 14, 22, 27, 17, 19, 17, 17, 22, 20, 22) > myMean <- function(assignment2) { + return(sum(assignment) / length(someData)) + } > myMean(assignment2) Show Traceback Rerun with Debug Error in myMean(assignment2) : object 'assignment' not found The function fails because of inconsistent variable names : You pass in "assignment2", but inside the function you try to use "assignment" and "someData...