I used this visualization challenge as a way to explore the relationship between population and GDP per capita. I designed a graph which displays population and GDP per capita. I added tooltips that show you which country you’re hovering over, its exact population and GDP per capita. This allows one to compare countries at a glance, but also with pinpoint precision, if it’s necessary. Overall, this dataset provided an easy basis from which I could create a useful and understandable interactive visualization.
library(tidyverse)
library(plotly)
# Load data here
library(gapminder)
Do the following:
geom_point()).gapminder_2002 <- filter(gapminder,
year == 2002)
plot_one <- ggplot(
data = gapminder_2002,
mapping = aes(x = pop, y = gdpPercap,
color = continent)) +
geom_point(aes(text = paste(country,
"<br>Population:", pop,
"<br>GDP per capita:", gdpPercap))) +
scale_x_log10() +
theme_minimal()
## Warning in geom_point(aes(text = paste(country, "<br>Population:", pop, :
## Ignoring unknown aesthetics: text
plot_one
Make the plot interactive with ggplotly().
Make sure the hovering tooltip is more informative than the default.
interactive_plot_one <- ggplotly(
plot_one, tooltip = "text"
)
interactive_plot_one
Good luck and have fun!
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.