Posts

Showing posts from March, 2025

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 . >> Report on your blog the success or failure in your debugging procedure. After inputting the code into Rstudio, i get the result:  Error: unexpected symbol in: " for (i in 1:nrow(x)) { outlier.vec[i] <- all(outliers[i,]) } return" After careful examination I noticed two issues. First, the structure of the function was not  aligned properly. This had to be modified in order for Rstudio to recognize the function.  Second, there appears to be &&.  &...

Module # 10 Building your own R package

Image
  Write your R package proposal for the  final project  on your blog posting. Plus, discuss your DESCRIPTION File and provide a link to your GitHub Yours The dataset I will be using is Video Game Sales (https://www.kaggle.com/datasets/anandshaw2001/video-game-sales). As mentioned in the description,  his package analyzes data from more than 16,500 games.  With it, we are able to see information such as the platform of the game,  year of release, genre, publisher, and sales from different regions. The  intention is to see trends over time and the relationship between regions and  sales. The description file has information such as Package, the title, version, description, depends, license, encoding, and lazydata. The trickiest section for me was depends. I am not too sure if I incorporated the right amount of information for that part. Overall, creating an R package was simple and exciting.  My github or  https://github.com/AlenjaksAbraha...

Module # 9 Visualization in R

Image
  In this module, we reviewed three types of visualization in R: basic visualization without any package, lettuce and ggplot2. Choose any data set for your visualization from Vincent Arel Bundock dataset list:  https://vincentarelbundock.github.io/Rdatasets/datasets.html Links to an external sit  Using this data, generate three types of visualization on the data set you have chosen. In your blog, discuss and present your three visualizations you will create and express your opinion on these three different types of graphics output. The dataset that I will be using is titled "Tips". This is an example dataset with values such as total_bill, tip, sex, smoker, day, time, and size. Below is a screenshot of the data.  Bar Chart The first graph I will be making is a simple bar chart that shows the total value of tips per day. This way we can see what day provides the most tips. From this chart, we are easily able to see that Saturday is the day with the most tips. Surprisi...

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

Image
 The file that was imported for this assignment is titled "Assignment 6 Dataset.txt" Before I began any coding I downloaded install.packages("plyr") and install.packages("pryr") then ran these libraries: require(pryr) require(ISLR) require(boot) library(data.table) library(plyr) For step 1 I imported the dataset by using read.table, which resulted in the code below: > #Step 1 > Student_assignment_6 <- read.table("C:/Users/alenm/OneDrive/Documents/LIS4370/ Assignment 6 Dataset.txt", header = TRUE, sep = ",") > Student_assignment_6 Name Age Sex Grade 1 Raul 25 Male 80 2 Booker 18 Male 83 3 Lauri 21 Female 90 4 Leonie 21 Female 91 5 Sherlyn 22 Female 85 6 Mikaela 20 Female 69 7 Raphael 23 Male 91 8 Aiko 24 Female 97 9 Tiffaney 21 Female 78 10 Corina 23 Female 81 11 Petronila 23 Female 98 12 Alecia 20 Female 87 13 Shemika...

Module # 7 R Object: S3 vs. S4 assignment

Image
Download any type of data (from the web or use datasets package) or create your own set.  Then, on the second step, determine if generic function as discussed in this module can be assigned to your data set, and if not, why? (Example, here is list of data set in R) data("mtcars") head (mtcars, 6) list(mtcars, 6) In third and last step, explore if S3 and S4 can be assigned to your data set.     First Step: The dataset that I will be using is a built in dataset that is found in R. It is "airquality" New York Air Quality Measurements Second Step: Generic functions can be assigned to this dataset. You can see from the images below.  Third Step: 1) How do you tell what OO system (S3 vs. S4) an object is associated with? By using class(), we are able to see the class of airquality.  From this, we can deduce that airquality is a S3 object as it falls under a data frame.  2) How do you determine the base type (like integer or list) of an object? To determine if the...