knitr::opts_chunk$set(echo = TRUE)
library(rdew)
rdew
provides data about a number of aspects of the game, such as animals, crops, hats, quests, NPC's, locations, monsters, and more. This
is an example analysis using the cooking recipes dataset as well as the
objects dataset, mean to demonstrate how to join a dataset to the objects
dataset to get info about objects that are dependencies.
The cooking recipes dataset contains information about recipes that can be cooked in your home kitchen. Some recipes require an unlock event, which can be found in the unlock_conditions
columns. Recipes also require ingredients, which can be found in the ingredients
column. Let's take a look.
tibble::glimpse(cooking_recipes)
As we can see, ingredients
has space-delimited integer values. Each of these space-delimited elements is the object id of an ingredient. How do we get more information about these items, such as the actual name of the item? By joining to the objects
dataset!
We will be joining to the object id's in the objects
dataset.
head(cooking_recipes)
When we join the cooking_recipes
dataset to the objects
dataset, they should join on the columns ingredient_id
and object_id
, respectively. We'll use a left join because the objects dataset contains many ingredients.
There are some columns in here that aren't necessary, such as the
geode_possible_items
, since geodes aren't ingredients to cooking recipes. Those columns will have NA's for all rows.
cooking_recipes_and_ingreds <- cooking_recipes %>% dplyr::left_join(objects, by = c("ingredient_id" = "object_id"), suffix = c("_yield", "_ingredient")) tibble::glimpse(cooking_recipes_and_ingreds)
Let's take a look at just the yield item and the required ingredients.
just_names <- cooking_recipes_and_ingreds %>% dplyr::select(name_yield, name_ingredient, ingredient_id, ingredient_quantity) head(just_names)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.