Task 1: Reflection

Learning to make better dashboards is one of the areas in which I would most like to increase my skill level. A few years ago I completed Coding for R in Policy Analytics and towards the end of the semester we completed interactive dashboards using traffic accidents. At the time, I was working on a long-term project with Atlanta Public Schools and, since it was 2020, all of our work had become virtual. Although they were far from perfect, I was able create dashboards for the schools we were working with displaying the data collected up to that point and share them with the schools. This ended up being really helpful not only in our communication with our collaborators, but when it came time to explain to our partners the work being done.

I am currently involved in a network analysis, and we have had some trouble getting people to participate. By their nature, network surveys are long and a bit tedious and we have struggled to convince organization members how useful this data could be for them. One thing that I would really like to try is to create dashboards showing their networks based on the data that we have now. There is something about being able to see the data and interact with it that I think tends to inspire questions and, hopefully, interest. There are so many questions that can be asked, like what happens to the network if we remove administrators? How connected – or dense- is our network? Is it diluted? Or clustered around a single person? When looking at a static visual, it can be easy to glaze over parts of it, to think you have processed it when you really have missed key parts. I feel that when you physically interact, turn variables on and off, etc. your brain is engaged in a different and more active manner. My hope, is that by seeing the networks, seeing the questions that can be asked with this data, we will engage their curiosity and encourage their participation.

Task 2: Interactive plots

library(tidyverse)
library(plotly)
library(tidyverse)
library(ggrepel)  
library(ggtext)  
library(dplyr)
library(ggrepel)
library(gapminder)
library(scales)
library(ggThemeAssist)
library(plotly)
library(flexdashboard)
library(ggThemeAssist)

gapminder_data <-gapminder

# Load data here

Do the following:

  1. Make a plot. Any kind of plot will do (though it might be easiest to work with geom_point()).
gapminder_asia <-
  gapminder_data %>%
    filter(continent == "Asia") %>%
  ggplot(aes(x = gdpPercap, lifeExp)) + 
  geom_point()+
  labs(x = "GDP Per Capita", y = "Life Expectancy",
      subtitle = "The Relationship Between GDP and Life Expectancy in Asia",
      caption = 1952 - 2007)

gapminder_asia

  1. Make the plot interactive with ggplotly().
ggplotly(gapminder_asia)
  1. Make sure the hovering tooltip is more informative than the default.
interactive_gapminder_asia <- 
  gapminder_data %>%
    filter(continent == "Asia") %>%
  ggplot(aes(x = gdpPercap, lifeExp)) + 
  geom_point(aes(text = country),
             position = position_jitter(width = 0, height = 0.15, seed = 1234))+
  labs(x = "GDP Per Capita", y = "Life Expectancy",
      subtitle = "The Relationship Between GDP and Life Expectancy in Asia",
      caption = 1952 - 2007)
## Warning in geom_point(aes(text = country), position = position_jitter(width =
## 0, : Ignoring unknown aesthetics: text
ggplotly(interactive_gapminder_asia, tooltip = "text")
labels_gapminder_asia <- 
  gapminder_data %>%
    filter(continent == "Asia") %>%
    mutate(graph_label = paste0(country, "<br>", 
                                year, "<br>",
                                "GDP per Capita: ", comma(gdpPercap), "<br>", 
                                 "Life Expectancy: ", lifeExp)) %>%
  ggplot(aes(x = gdpPercap, lifeExp, color = year)) + 
  geom_point(aes(text = graph_label),
             position = position_jitter(width = 0, height = 0.15, seed = 1234))+
  labs(x = "GDP Per Capita", y = "Life Expectancy",
      subtitle = "The Relationship Between GDP and Life Expectancy in Asia",
      caption = 1952 - 2007, 
      color = "Year")
## Warning in geom_point(aes(text = graph_label), position = position_jitter(width
## = 0, : Ignoring unknown aesthetics: text
ggplotly(labels_gapminder_asia, tooltip = "graph_label")

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.