Task 1: Reflection

Put your reflection here

Task 2: Interactive plots

I chose to go to Kaggle and get a dataset of pokemon I added a new column to have a the total stats of each pokemon

library(tidyverse)
library(plotly)

# Load data here
pokemon <- read_csv("/Users/laurenharvey/Desktop/Scool Ish/ISTA 320/DataViz07/data/pokemon.csv")

# Create a new dataframe with the 'total_stats' column
pokemon_total <- pokemon %>%
  mutate(total_stats = hp + attack + defense + sp_attack + sp_defense + speed)

# Display the first few rows of the new dataframe
head(pokemon_total)

Do the following:

  1. Make a plot. Any kind of plot will do (though it might be easiest to work with geom_point()). I initially wanted see if I did a box plot and show good representation of every tyrpes max sdtats.
pokemon_total %>%
  ggplot(aes(x = type1, y = total_stats)) +
  geom_boxplot(fill = "lightblue") +
  labs(title = "Total Stats by Pokémon Type",
       x = "Type",
       y = "Total Stats") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

The next plot I thought of is dropping every pokemon in a scatter plot based on typ that almost appears mor like a histogram

pokemon_total %>%
  ggplot(aes(x = type1, y = total_stats)) +
  geom_point(color = "darkgreen", alpha = 0.6) +
  labs(title = "Total Stats vs Type",
       x = "Type",
       y = "Total Stats") +
  theme_minimal()

The next plot I wanted to see is a bar plot measure the average total stats of each typing.

pokemon_total %>%
  group_by(type1) %>%
  summarize(avg_total_stats = mean(total_stats, na.rm = TRUE)) %>%
  ggplot(aes(x = reorder(type1, -avg_total_stats), y = avg_total_stats)) +
  geom_bar(stat = "identity", fill = "purple") +
  labs(title = "Average Total Stats by Pokémon Type",
       x = "Type",
       y = "Average Total Stats") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

  1. Make the plot interactive with ggplotly().

For my interactive plot Took a first looked at being able to look at plots of individulal pokemon.

scatter <- pokemon_total %>%
  ggplot(aes(x = type1, y = total_stats)) +
  geom_point(color = "darkgreen", alpha = 0.6) +
  labs(title = "Total Stats vs Type",
       x = "Type",
       y = "Total Stats") +
  theme_minimal()

# Convert to an interactive plot with ggplotly
ggplotly(scatter)
  1. Make sure the hovering tooltip is more informative than the default. To make this more informative i modified the text show the max stats and the name of the pokemon by hovering over the points.
scatter_ <- pokemon_total %>%
  ggplot(aes(x = type1, y = total_stats, text = paste("Name:", name,"<br>Total Stats:", total_stats))) +
  geom_point(color = "darkgreen", alpha = 0.6) +
  labs(title = "Total Stats vs Type",
       x = "Type",
       y = "Total Stats") +
  theme_minimal()

ggplotly(scatter_, tooltip = "text")

Good luck and have fun!

Task 3:

Install the {flexdashboard} package and create a new R Markdown file in your project by going to File > New File… > R Markdown… > From Template > Flexdashboard.

Using the documentation for {flexdashboard} online, create a basic dashboard that shows a plot (static or interactive) in at least three chart areas. Play with the layout if you’re feeling brave.