Written Analysis

For this portfolio project, I decided to revisit a homework problem that I worked on in the past. I recalled recreating a graph on the CIA countries dataset, and I thought there was a lot of potential to add interactivity to it to enhance the static version of the graph. Given the CIACountries dataset, which contains rich information on 236 countries across seven variables like GDP, education spending, and internet usage, the static graph provides a valuable overview. However, it falls short in allowing for detailed exploration of individual countries and nuanced data patterns. I wanted to address this by adding two interactive components: Plotly and datatable. I chose Plotly because of its ability to provide immediate and on-demand information through tooltips. By incorporating Plotly, we enable users to instantly identify specific countries within the scatter plot through tooltips, and overcomes the limitation of visual estimation, especially crucial when distinguishing countries with similar data points in this case. Also, the addition of the interactive DT table allows users to filter and sort the dataset, which allows them to investigate specific subsets of countries based on criteria such as high internet usage or specific ranges of GDP. This interactivity is important this dataset and accompanying graph, as it allows users to dive deeper into the data, and validate observations made from the graph as well as explore relationships that might be harder to find in the static visualization.

Interactive Graph

CIACountries = mdsr::CIACountries

new_plot <- ggplot(CIACountries, aes(x = educ, y = gdp, size = roadways, color = net_users, text = country)) +
  geom_point(alpha = 0.8) +
  scale_x_continuous(breaks = c(0, 5, 10), minor_breaks = c(0, 2.5, 5, 7.5, 10, 12.5)) +
  scale_y_continuous(trans = "pseudo_log", 
                     breaks = c(50000, 100000, 150000),
                     labels = label_comma()) +
  scale_color_viridis_d(direction = -1, option = "magma", guide="none") +
  scale_size_continuous(range = c(1, 10),
                       breaks = c(0.1, 1, 10)) +
  facet_wrap(~net_users, scales = "fixed", nrow=1) +
  theme_minimal() +
  theme(
    panel.grid.major = element_line(color = "gray80", size = 0.1),
    panel.grid.minor = element_line(color = "gray90", size = 0.1),
    legend.position = "bottom"
  ) +
  guides(size=guide_legend(title = "roadways")) +
  labs(
    title = "Relationship between GDP, Education, and Roadways",
    x = "educ",
    y = "gdp"
  )

ggplotly(new_plot, tooltip = "text")
library(DT)
datatable(CIACountries, rownames = FALSE, filter = "top") %>%
  formatStyle(columns = colnames(CIACountries), fontSize = '13pt')