Posts

Showing posts from March, 2026

Building Your Own R Package

I would like to make a package that allows culinary students, chefs, or even just people cooking at home, to analyze and filter thousands of different recipes in a more simplified manner. It would allow them to find specific recipes based on ingredients, preparation time, type of meal, etc. It would also generate visualizations to easily compare different types of recipes based on their characteristics. This package will help them save time, explore new recipes, and view trends. Key functions that I would include are finding a specific recipe (find_recipe), outputting a random recipe (random_recipe), filtering the recipes by ingredients you have (filter_ingredient), and creating graphs to compare recipes by different characteristics (plot_time). I will think of more after further exploring the dataset. I hope this proposal  meets the final project requirements. I was struggling to come up with an idea and realized I love to cook, but I often struggle with new things to make or what...

Comparing Visualization Systems in R: Base Graphics, Lattice, and ggplot2

Image
How do the syntax and workflow differ between base, lattice, and ggplot2? Base R has a simple function depending on the graph; you just need the specific variables and can label them to create an easy-to-read basic graph. Lattice is good for comparing multiple variables by group, two graphs side by side, using a formula-based syntax. ggplot2 uses multiple functions to create a more advanced graph. Can customize a wider range of aspects to the visualizations, including background, color, or shape in a much easier way. Which system gave you the most control or produced the most “publication‑quality” output with  minimal code? The ggplot2 system gave me the most control and produced a higher quality output compared to the other two. It gives clearer visuals with color comparison and automatically adds legends with minimal code. An y challenges or surprises you encountered when switching between systems? My main challenge was with ggplot2, which has a lot more functions to memorize com...

Input/Output, String Manipulation and Plyr

Image
First, I had to install the plyr package in RStudio. install.packages("plyr") library(plyr) For step one, I downloaded the assignment 6 dataset text file to my computer and imported it into R. At first, I had  "<FileName>.txt" in the read line, but I was getting the error " cannot open file Assignment 6 Dataset.txt': No such file or directory", so I changed it to  file.choose().  Then it was reading the text as only one column when trying to find the object Sex, resulting in "Error in FUN(X[[i]], ...) : object 'Sex' not found." To fix this, I had to make sure the read line had sep = "," because the file is comma-separated for columns. #Step 1 student_assignment_6 <- read.table(file.choose(), header = TRUE, sep = ",") Using the ddply function, I calculated the mean by the Sex category. We can see that the new file is now organized with the females in rows 2-17 and the males in rows 18-21, with a new column ...

S3 vs. S4

Using the built-in dataset iris in R, which represents the measurements of iris flowers, I tried a few generic functions to see if they could be assigned to the data set. data("iris") class(iris) print(iris) summary(iris) head(iris, 3) The generic functions print, summary, and head all work on the dataset iris because it has the data.frame class. Methods already exist for this class, so the function is called automatically.  Since class(iris) returns "data.frame" but isS4(iris) returns FALSE, I know that iris is already an S3 object. S4 can be assigned to the dataset by creating an S4 class and converting it. 1. How do you tell what OO system (S3 vs. S4) an object is associated with?       isS4( ) will test if an object is S4, resulting in TRUE or FALSE. If FALSE, then do is.object( ), and if that is TRUE, the object is S3. 2. How do you determine the base type (like integer or list) of an object?      typeof(object) will define the base type of an obj...