Posts

Showing posts from March, 2025

Module # 11 Debugging and defensive programming in R

Issaiah Jennings Module # 11 Debugging and defensive programming in R The code below contains a 'deliberate' bug! tukey_multiple <- function(x) { outliers <- array(TRUE,dim=dim(x)) for (j in 1:ncol(x)) { outliers[,j] <- outliers[,j] && tukey.outlier(x[,j]) } outlier.vec <- vector(length=nrow(x)) for (i in 1:nrow(x)) { outlier.vec[i] <- all(outliers[i,]) } return(outlier.vec) } > Find the bug and fix it. tukey_multiple <- function(x) { outliers <- array(TRUE, dim = dim(x)) for (j in 1:ncol(x)) { outliers[, j] <- outliers[, j] & tukey.outlier(x[, j]) } outlier.vec <- vector(length = nrow(x)) for (i in 1:nrow(x)) { outlier.vec[i] <- all(outliers[i, ]) } return(outlier.vec) } I fixed a bug in the tukey_multiple function. I was using && for comparisons, but I needed & instead. After the fix, the function worked correctly.

Module # 10 Building your own R package

Issaiah Jennings Module # 10 Building your own R package Package: Jennings Title: Data Visualization Tools Version: 0.0.0.9000 Authors@R: Authors@R: c(person("Issaiah", "Jennings", email = "icarterjennings@usf.edu", role = c("aut", "cre"))) Description: A package for creating data visualizations using base R, lattice, and ggplot2.  It helps users generate clear and effective plots for data analysis Depends: R (>= 3.1.2) License: CC0 LazyData: true The Jennings package is for students and anyone looking to make data visualizations in R without too much hassle. It includes simple functions to create plots using base R, lattice, and ggplot2, so you can explore different styles without switching tools. This package is meant to make it easier to generate clear, professional-looking charts for class projects, research, or personal data analysis. https://github.com/Ijennin/R-Functions/blob/278e176fbbe3209edd5ff5fc5bd9d03df49e5145/Module%20...

Module # 9 Visualization in R

Image
Issaiah Jennings Module # 9 Visualization in R In this project, I explored the ShipAccidents.csv dataset and created three visualizations in R: a basic histogram, a bar plot using Lattice , and a customized bar chart with ggplot2 . The first visualization I made was a basic histogram showing the distribution of ship service years . This quick and simple plot helped me understand how service years are spread out across ships. It was useful for spotting extreme values, but it lacks customization options, making it more suitable for initial exploration rather than detailed analysis. Next, I used Lattice to create a bar plot showing the number of incidents by ship type . This method helped me categorize the incidents by ship type, offering a clear visual of which ship types have more accidents. While Lattice is great for grouped data, it’s less flexible in terms of customization compared to ggplot2 . Finally, I used ggplot2 to create another bar chart of incidents by ship type, bu...

Module # 8 Input/Output, string manipulation and plyr package

Image
Issaiah Jennings Module # 8 Input/Output, string manipulation and plyr package For this assignment, I worked with a dataset containing student information such as their name, age, sex, and grade. The first thing I did was import the data from a .txt file on my Desktop into R using the read.delim() function. Once the data was in R, I renamed the columns for clarity so they were easier to work with. After that, I used the plyr package to calculate the average grade based on gender by grouping the data by the "Sex" column and applying the mean() function. Next, I filtered the data to only include students whose names contained the letter "i," using the grepl() function. Finally, I saved the results of the mean grade calculation into a text file and exported the filtered student names to a CSV file, which I saved on my Desktop. > # Install and load required packages > library(plyr) > > # Read the dataset with read.delim() assuming it's tab-separated ...