Pokémon API - Group Project
Today, our first group project is due. The project was to create a vignette about contacting an API using functions we’ve created to query, parse, and return well-structured data.
For my portion of the project 2, I completed the following:
-
The
rmarkdown::render
file and setup the repo space. Using the instructions and concept similar to one of the assignments, I created a R file that containedrmarkdown::render("Project2.Rmd", "github_document","README.md")
When you run the code, it knits and places the markdown information in the README.md file. -
Function
get_berry()
to get the berry information. The berry function was created using information from “How to access a Restful API in R”. It loops through the api until we receive information on all 64 berries. Then combines the data into a data frame. -
Function
get_moves()
to get basic moves. As I will mention later, this api has overlapping endpoints (and okay documentation) which maked it difficult to understand what is begin pulled and how it related to basic Pokémon information. I decided to use just the basic move endpoint because it accessed all 826 Pokémon. -
Function
get_pokemon()
to get the individual Pokémon info requested by user. I pulled the unstructured data from the api and saved it into a variable. using [[ ]] I parsed off the items needed and placed everything into atibble()
that was returned by the function. -
Functions to call type and encounter endpoints, which we decided not to use.
-
Scatter plot for berries. The most interesting finding was as a berry grows, the soil becomes drier. It was interesting because it was one of the few items that had a relationship and created an okay plot.
-
Scatter plot for BMI vs Speed. We needed to create a new variable with the data, so I decided we should use BMI (wt/ht) to see if there was a relationship with speed. There was no relationship. The Pokémon with the largest BMI is not the slowest.
-
Numeric summary for berries. I removed a few of the variables, because it did not make sense to run a summary on them. Afterwards, I used
summary()
. For the remaining variables, there was very little variation between the mean and median. Those values were not equal, so you can expect for the shape to be skewed slightly. The exceptions were size and soil dryness, the difference was relatively large, so I would expect for those plots to be right skewed. -
Bar plot with Flavor segmented by firmness, we decided not to use. The berry data frame made some great looking plots; however, the plots either didn’t make any sense or even when segmented they produced the same image. It seemed even though the data was different, it had the same distribution. That was interesting.
-
Besides the plots above, added interpretation to bar plot (habitat and color) and numeric summary for pokemon stats.
- Bar plot with berry segmented by color, we decided not to use.
- Histogram for berries, we decided not to use.
- Histogram for weight of pokemon, we decided not to use.
- Correlation growth and soil dryness, we decided not to use.
The most difficult part of this project was getting the endpoints from the poke api which seem to overlap. Also, some endpoints have 1 item and others have 200 items. So, the plan was to pull all endpoints and combine them into a data frame. That did not work for me. I think I spend days trying to find a way – filling rows with 0s or NAs to create a data frame. In the end, I settled for being less ambitious with the project. I decided to access the basic move endpoint which had access to all pokemon. Then pulled 3-4 other endpoints around moves and damage, but only retuned one data point.
Approaching a similar project in the future, if it’s a project for class and I have options – I would choose a different API. I chose poke api for our team. Otherwise, for a personal project or work, it’s important to understand how the information is being returned from the API. It’s not cookie cutter. As mentioned above, I thought we would have smooth sailing pulling the api information and converting it to a data frame. However, if the rows and/or columns are not the same, you will encounter an error. I would also try not to make the process so complicated. I think I was overthinking it. Now that I can look back, the project does seem to be as bad. It was challenging, but I learned a lot. I plan to create a separate project with the portion I completed and try to pull additional information from that api. Later, try to pull from NASA api.
Our Pokémon Vignette