Skip to main content

Posts

Showing posts from October, 2024

Week 9 : Exploring Cancer Survival Data Visualization in R

 Week 9 : Exploring Cancer Survival Data Visualization in R In this Assignment, I explored ways to visualize cancer survival data across different organs using a variety of R plotting methods, including base R’s   barplot() ,   ggplot2 , and an   xyplot()   with   lattice . Here’s a breakdown of the journey, the challenges faced, and what I learned along the way. The Data: Mean Survival Time by Organ The dataset I worked with contains information on the survival times across different organs from cancer . To understand the average survival time for each organ, I first calculated the mean survival time by using the following code: Once I had the mean survival times, I set out to visualize the data using four different approaches, each with its unique set of functionalities and aesthetics. 1. Basic Bar Plot with Base R My first plot used a simple   barplot()   to display the mean survival times. This method provided a quick and straightforward way t...

Week 8 : Tackling Data Handling Challenges and Finding Solutions

 Week 8 : Tackling Data Handling Challenges and Finding Solutions This time i had the opportunity to dive deeper into R by using the plyr package to compute the mean of grades split by gender and export the results to a file. The task seemed straightforward: import a dataset, perform some basic operations, and output the result. However, as with most programming journeys, I encountered a few hurdles along the way, leading to a wealth of learning. Step 1: Importing the Dataset The first task was to import a dataset into R. I used the read.table() function, which reads the file in a tabular format. Initially, the command worked well, but I did face a minor challenge when choosing the right separator for the CSV file ( sep="," ). This was an easy fix once I realized the file used commas to separate values. Here's the command that worked: Lesson learned: Always double-check the file format and ensure the separator used in the file is correctly specified. Step 2: Calculatin...

Object-Oriented Programming in R: Challenges and Insights from the "Murders" Dataset

 Object-Oriented Programming in R: Challenges and Insights from the "Murders" Dataset As part of my recent assignment on Object-Oriented Programming (OOP) in R , I delved into applying both the S3 and S4 object systems to the "murders" dataset from the dslabs package. Through this experience, I encountered some interesting challenges, particularly with S4 objects, and learned a lot about the flexibility and formal structure that R's object systems offer. The dataset provided data on murder rates across U.S. states, and my task was to determine how these object-oriented systems can be applied, test the use of generic functions, and explore key concepts like object classes, slots, and methods. Here’s a reflection on what I learned and the hurdles I faced along the way. Assigning Generic Functions to the Murders Dataset In R, generic functions like summary() and print() are widely used to extract basic information about objects, especially data frames. Since ...

Matrix Operations and Bioinformatics Insights: Week 6

 Matrix Operations and Bioinformatics Insights: Week 6 This week, I worked on an assignment focused on using R for matrix operations and did some bioinformatics practice related to CDR3 sequences. Here's a simple breakdown of what I did and my takeaways. What I Did This Week Adding and Subtracting Matrices I started by creating two matrices, and then added and subtracted them using R. Here's the code I used: This code performs basic matrix operations, and it was a good way to understand how matrix math works in R. Building a Diagonal Matrix Next, I used the diag() function to create a matrix with specific values on the diagonal. The code looked like this: Creating a Custom Matrix I then built a matrix with specific values in the rows and columns > diag(3,5). Here's how I did it: This code sets up the matrix with a diagonal of 3 and modifies the first row and column. It was a fun challenge that helped me see how to control matrix structure using R’s indexing features. Bi...