Posts

Showing posts from March, 2026

Assignment #10: Building Your Own R Package

Assignment #10: Building Your Own R Package Purpose The Friedman package is designed to help students like me and researchers perform efficient exploratory data analysis in R. It provides tools for data cleaning, summarizing, and visualizing datasets, making common workflows faster and easier. The package is aimed at beginners and intermediate R users who want a consistent set of functions for analyzing data without having to write repetitive code. Key Functions Here are some planned functions: clean_data(): Standardizes column names, handles missing values, and formats data frames for analysis. summarize_data(): Provides summary statistics for numeric and categorical columns, including counts, means, medians, and standard deviations. plot_distribution(): Generates histograms, density plots, and boxplots for selected variables. compare_groups():  Performs group-wise comparisons and outputs summary tables and plots. DESCRIPTION Choices Dependencies (Imports): I included ggplot2 and ...

Assignment #9: Visualization in R – Base Graphics, Lattice, and ggplot2

Image
  Base Graphics, Lattice, and ggplot2 This scatter plot shows the relationship between vehicle weight (wt) and fuel efficiency (mpg) using base R graphics. Each point represents a car in the dataset. The plot reveals a clear negative relationship, where MPG decreases as weight increases. Lighter cars tend to have much higher fuel efficiency, while heavier cars fall into lower MPG ranges. This suggests that vehicle weight is a strong predictor of fuel economy. This histogram displays the distribution of fuel efficiency (mpg) across all cars in the dataset. The x-axis represents MPG ranges, while the y-axis shows the number of cars in each range. Most vehicles fall between 15 and 25 MPG, indicating that moderate fuel efficiency is the most common. The distribution is slightly skewed toward higher MPG values, with fewer cars achieving very high efficiency. Overall, the dataset is concentrated in the lower-to-mid MPG range. This lattice scatter plot shows the relationship between weigh...

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

Input/Output, string manipulation and plyr package

Module # 7 R Object: S3 vs. S4 assignment

Image
For this assignment, I used the built-in R dataset mtcars, which comes from the R datasets package. data("mtcars") head(mtcars, 6) The mtcars dataset contains information about different car models, including: mpg (miles per gallon) cyl (number of cylinders) hp (horsepower) wt (weight) am (transmission type) To check its structure, I got this below: Output shows: Class: "data.frame" Base type: "list" A good question to ask is if a generic function can be assigned to this  A generic function in R is a function that behaves differently depending on the class of the object passed to it. For example: Both print() and summary () are generic functions. And to check if a function is generic: methods(summary) This shows different methods like: summary.data.frame summary.lm Since mtcars is a data.frame, R automatically dispatches: summary.data.frame(mtcars) A Generic Function Be Assigned Because mtcars is an S3 object,  data.frame is an S3 class, gene...