Task 1: Reflection

PPI has historically been lower than CPI. This makes sense since PPI applies more accurately measures wholesale prices while CPI more accurately measures products and services after retail markups. In the past five years both indexes have increased substantially.

The data I used here was sourced from The US Bureau of Labor Statistics: https://www.bls.gov/cpi/data.htm https://www.bls.gov/ppi/databases/

Task 2: Interactive plots

library(tidyverse)
library(plotly)
library(patchwork)

# Load data here
cpi_data <- read.csv("C:/Users/valde/Desktop/november_08/data_challenge_seven/data/consumer_price_index.csv")
ppi_data <- read.csv("C:/Users/valde/Desktop/november_08/data_challenge_seven/data/producer_price_index.csv")

# this selects every single row except the last one which i wanted to remove
cpi_data <- head(cpi_data, -1)
cpi_plot <- ggplot() +
  geom_point(data = cpi_data, aes(x = Year, y = Dec, color = "CPI")) +
  labs(title = "Yearly Consumer Price Index",
       x = "Year",
       y = "Index Value") +
  theme_minimal()

interactive_plot_cpi <- ggplotly(cpi_plot)
interactive_plot_cpi
ppi_plot <- ggplot() +
  geom_point(data = ppi_data, aes(x = Year, y = Dec, color = "PPI")) +
  labs(title = "Yearly Producer Price Index",
       x = "Year",
       y = "Index Value") +
  theme_minimal()

interactive_plot_ppi <- ggplotly(ppi_plot)
interactive_plot_ppi
# CPI and PPI plot
cpi_plot <- ggplot() +
  geom_point(data = cpi_data, aes(x = Year, y = Dec, color = "CPI")) +
  labs(title = "Yearly Consumer and Producer Price Index",
       x = "Year",
       y = "Index Value") +
  theme_minimal()

# Add PPI data to the same plot
cpi_ppi_plot <- cpi_plot +
  geom_point(data = ppi_data, aes(x = Year, y = Dec, color = "PPI"))

interactive_plot_cpi_ppi <- ggplotly(cpi_ppi_plot)
interactive_plot_cpi_ppi