Final Project
The R Package that I have implemented is titled "Video Game Sales". The dataset was originally from Kaggle. This package analyzes data from more than 16,500 games. We can see information such as platform of the game, year of release, genre, publisher, and sales from different genres. The goal of this package is to locate trends over time and the relationship between regions and sales.
I focused on building 4 functions.
sales.over.time:
This function focused on aggregated video game sales by Year for a selected region. The regions include: Global, North America, Europe, Japan, and Other. With this function, the output results in a printed data frame of yearly sales as well as a line plot that demonstrates trends over time. I also added some extra details in the line plot such as angled x-axis for easier readability.
> sales.over.time(VideoGames, region = "NA")Which would result in this:
Year Sales
1 1980 10.59
2 1981 33.40
3 1982 26.92
4 1983 7.76
5 1984 33.28
6 1985 33.73
7 1986 12.50
8 1987 8.46
9 1988 23.87
10 1989 45.15
top.selling.games:
This function sorts and returns the top best-selling video games in a given region. The output results in a table of the top games with columns like name, platform, year, genre, publisher, and sales. Testing is relatively simple. The only thing you need to input is the amount values you want to see and the specific region.
The first example is Japan with the three games with the highest unit of sales.
top.selling.games(VideoGames, n = 3, region = "JP")
Name Platform Year Genre Publisher JP_Sales
5 Pokemon Red/Pokemon Blue GB 1996 Role-Playing Nintendo 10.22
13 Pokemon Gold/Pokemon Silver GB 1999 Role-Playing Nintendo 7.20
2 Super Mario Bros. NES 1985 Platform Nintendo 6.81
The second example is Global with the five games with the highest amount of sales. | |
> top.selling.games(VideoGames, n = 5, region = "Global")
Name Platform Year Genre Publisher Global_Sales
1 Wii Sports Wii 2006 Sports Nintendo 82.74
2 Super Mario Bros. NES 1985 Platform Nintendo 40.24
3 Mario Kart Wii Wii 2008 Racing Nintendo 35.82
4 Wii Sports Resort Wii 2009 Sports Nintendo 33.00
5 Pokemon Red/Pokemon Blue GB 1996 Role-Playing Nintendo 31.37
|
as.videogame.object:
This function constructs a formal S3 object of class "VideoGame". With this, it produces a single-row data frame representing a single video game. The intention of this function is to show simple S3 representation.
> row <- VideoGames[1, ] > vg <- videogame(row) > class(vg) [1] "videogame"
build.videogame.class:
This function creates a new S4 object of class "VideoGame" using the provided values for the game's name, platform, and global sales. To test this, I looked at a familiar game, duck hunt, and inputted information.
duck_hunt <- new("VideoGame",
name = "Duck Hunt",
platform = "NES",
sales = 28.31)
Below is the result:
> duck_hunt
An object of class "VideoGame"
Slot "name":
[1] "Duck Hunt"
Slot "platform":
[1] "NES"
Slot "sales":
[1] 28.31Breakdown of project process:
Building an R package was a challenging process for me. At first it was very overwhelming. I felt like I had no idea where to start. Based on previous assignments, I already had a dataset chosen as well as a description for the package I was going to work with.
I started building my functions. After I felt satisfied with the functions I built, I moved towards the building of the package. A mistake I made was not creating a new project for my work. I thought I could use the same one I used throughout the semester. This was not viable. I went to Github and created a new repository. After that I was able to link the new repository to Github.
After that, I started working on fixing the readme file, the description file, and the rmd file. I wanted to ensure everything was complete before committing and pushing my work. This was a crucial mistake because I worked too fast and did not check my work. I was able to commit everything to Github. However, when I tried to load my package, issues came up. At first I believed it may have been a spelling error but that was not the issue. I resorted to Chatgpt to help me with this problem. I was informed that it could be a token issue which I repeatedly changed and updated. After working on this for hours, I asked chatgpt to go through each file I uploaded to spot any errors. To my surprise, this major issue was caused by a simple parenthesis that was missing from the description file. I was able to fully test my package with satisfactory results. I also had to remove my description file from the "man" file as it was causing major errors.
As frustrating as that was, creating a fully fleshed out package was rewarding and challenging. With the chosen dataset and the various functions that I implemented, I believe other users can gain valuable insights from these trends and patterns. Not only did I want to focus on the global impact that video games have played over the last few decades, I also wanted to utilize ggplot to visualize these relationships in digestible ways. Another task that I was happy to implement was the S3 and S4 "functions". This has been a confusing topic for me so I made it a priority to break it down into recognizable examples through video games so that other users can grasp this information.
Overall, the topics that were taught in LIS4370 allowed me to create an R package that could be used to help other students understand R, but also be built upon so that I can further master my understanding of this challenging, complex, but also insightful platform.
Github Link for my r package > vgSalesAnalyzer
or
https://github.com/AlenjaksAbraham/vgSalesAnalyzer

Comments
Post a Comment