Exercise

Explore cuisines: wordclouds

Hope you are having fun building these foody Shiny apps! A handy way to visualize a lot of data is wordclouds. In this exercise, you will extend the Shiny app we built previously and add a new tab that displays the top distinctive ingredients as an interactive wordcloud.

An app displaying an interactive wordcloud of top ingredients by chosen cuisine

We have already loaded the packages shiny, dplyr, ggplot2, plotly, and d3wordcloud. Here is a handy snippet to create a wordcloud.

d3wordcloud(
  words = c('hello', 'world', 'good'), 
  freqs = c(20, 40, 30),
  tooltip = TRUE
)

Instructions

100 XP
  • UI: Add a d3wordcloudOutput() named wc_ingredients, and wrap it in a tabPanel(). This should be the first tabPanel() in your app.
  • Server: Render an interactive wordcloud of top ingredients and the number of recipes they get used in, using d3wordcloud::renderD3wordcloud() and assign it to an output named wc_ingredients. You'll need to use the reactive expression rval_top_ingredients() to return a data frame of the top ingredients with recipe counts.