Explore cuisines: top ingredients
Food has universal appeal, and the amazing array of dishes one can concoct
with the multitude of ingredients leads to near infinite variety! In this
exercise, you will use a dataset named recipes that contains recipes, the
cuisine it belongs to, and the ingredients it uses, to build a Shiny app that
lets the user explore the most used ingredients by cuisine.
Your final app should resemble the image in this screenshot.

We have already loaded the packages shiny and dplyr, as well as the
dataset recipes. Additionally, here is a handy snippet of code that
gets you the top 10 ingredients used in Greek cuisine. You will find this
useful to create the interactive data table in the app based on the cuisine
and number of ingredients selected by the user.
recipes %>%
filter(cuisine == 'greek') %>%
count(ingredient, name = 'nb_recipes') %>%
arrange(desc(nb_recipes)) %>%
head(10)
Este ejercicio forma parte del curso
Building Web Applications with Shiny in R
Instrucciones del ejercicio
- UI:
- Add an input in the sidebar named
cuisineto let users select a cuisine from the full set of cuisines available in therecipesdataset. - Add a slider input named
nb_ingredientsin the sidebar to let users select the number of ingredients to display. - Add an interactive data table output in the main panel named
dt_top_ingredients.
- Add an input in the sidebar named
- Server:
- Filter
recipesbased on the selected cuisine and number of top ingredients to display. - Render the filtered data as an interactive data table.
- Assign it to an output object named
dt_top_ingredients.
- Filter
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
ui <- fluidPage(
titlePanel('Explore Cuisines'),
sidebarLayout(
sidebarPanel(
# CODE BELOW: Add an input named "cuisine" to select a cuisine
# CODE BELOW: Add an input named "nb_ingredients" to select # of ingredients
),
mainPanel(
# CODE BELOW: Add a DT output named "dt_top_ingredients"
)
)
)
server <- function(input, output, session) {
# CODE BELOW: Render the top ingredients in a chosen cuisine as
# an interactive data table and assign it to output object `dt_top_ingredients`
}
shinyApp(ui, server)