knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width=4, 
  fig.height=3, 
  dpi=150
)
library(extrafont)
loadfonts(quiet = TRUE)
library(rdew)
library(ggplot2)

Introduction

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 trapped fish dataset, meant to demonstrate an exploratory data analysis using this package.

Trapped Fish

The trapped_fish dataset contains information about fish that are trapped, such as clams and lobsters (as opposed to fish caught with a fishing pole). We can take a peek at the data, which has variables object_id, name, type, chance, unused, location, min_size, and max_size. You can get the full information with ?trapped_fish.

trapped_fish

We can plot the trapped fish's min and max size by name (with some extra styling to make it look pretty^1^).

long_fish <-
  trapped_fish %>% 
  tidyr::pivot_longer(cols = c("min_size", "max_size"),
                      names_repair = "minimal",
                      names_to = "size_type",
                      values_to = "size_value")

styling <- 
    theme(panel.background = element_rect(fill = "floralwhite"),
        title = element_text(family = "Hello Sailor", size = 20),
        axis.text = element_text(family = "Hello Sailor", 
                                 size = 10),
        axis.text.x = element_text(angle = 45,
                                   vjust = 0.6),
        axis.title = element_text(size = 12),
        axis.title.y = element_text(margin = margin(r = 20)))

ggplot(long_fish,
       aes(x = name, y = size_value)) +
  geom_line(color = "turquoise4") +
  labs(title = "Trapped Fish Sizes", x = "Name", y = "Min to Max Size") +
  theme_classic() #+
  # styling

We could also color-code the fish by the location type (freshwater or saltwater). It looks like most trapped fish are saltwater, not freshwater, and that crabs and lobsters have the largest size range.

ggplot(long_fish,
       aes(x = name, y = size_value, color = location)) +
  geom_line() +
  scale_color_manual(values = c("freshwater" = "turquoise4",
                                "ocean" = "navy")) +
  labs(title = "Trapped Fish Sizes", x = "Name", y = "Min to Max Size") +
  theme_classic() +
  # styling +
  theme(legend.position = "bottom",
        # legend.text = element_text(family = "Hello Sailor", size = 12),
        legend.title = element_text(size = 14))

^1^ The font used in these charts is Hello Sailor by Out Of Step Font Company, which you can find here.



aftonsteps/rdew documentation built on Dec. 18, 2021, 11:21 p.m.