Posts

Showing posts from October, 2025

Assignment 9

Image
  Assignment 9: Visualization in R – Base Graphics, Lattice, and ggplot2 Objectives Compare three major visualization systems in R: Base graphics , Lattice , and ggplot2 . Apply all three to the same dataset to observe syntactic , conceptual , and visual differences . Produce clear, reproducible code and interpret key findings. Dataset Overview For this assignment, I used the Breast Cancer Wisconsin Diagnostic dataset ( brca ) from the dslabs package — a common bioinformatics dataset used to classify tumor samples as Benign (B) or Malignant (M) based on cell nucleus measurements. This dataset contains features computed from breast mass cell nuclei. brca$y = Diagnosis (Benign or Malignant) brca$x = 30 numeric features describing cell characteristics Load and explore the data # Load libraries and dataset install.packages("dslabs") library(dslabs) data("brca") # 'brca$y' contains the diagnosis (Benign/ Malignant) # 'brca$x' is a matrix of 30...

Assignment 8

Image
  Assignment 8 — Input/Output, String Manipulation, and the plyr Package Objectives This assignment focused on using R to handle input/output operations , perform data summarization using the plyr package, and apply string manipulation techniques. By completing this exercise, I learned how to import data files, compute grouped statistics, filter data based on character patterns, and export processed results in multiple formats. R Code # Step 1: Import dataset into R # Choose file interactively or specify directly student6 <- read.table(   file.choose(),       header = TRUE,   sep = ",",   stringsAsFactors = FALSE ) # Step 2: Install and load plyr package install.packages("plyr") library(plyr) # Compute mean Grade by Sex gender_mean <- ddply(   student6,   "Sex",   summarise,   GradeAverage = mean(Grade, na.rm = TRUE) ) # Step 3: Write the grouped means to a text file write.table(   gender_mean,   file = "gend...

Assignment 7

Image
  Assignment 7: Exploring R’s Object-Oriented Systems (S3 & S4) In this assignment, I explored R's object-oriented systems, focusing on S3 and S4 classes. The objective was to understand how R dispatches generic functions based on object class and to practice creating and manipulating S3 and S4 objects. Objectives The goal of this assignment was to explore R’s two primary object-oriented systems— S3 and S4 —and understand how generic functions work with different object types. Specifically, we: Selected and inspected a dataset. Tested base R generic functions. Created custom S3 and S4 objects. Compared the behavior and structure of both systems. R Code Step 1: Loading the Dataset We begin by using one of R’s built-in datasets, PlantGrowth , which measures the effect of different treatments on plant growth. # Load dataset data("PlantGrowth") head(PlantGrowth) # Describe structure str(PlantGrowth) Output:  Step 2: Test Generic Functions # Summarize datas...