Skip to contents

This function sorts recipes based on a specified column and order.

Usage

sort_recipes(data, sort_by, ascending = TRUE)

Arguments

data

Data frame containing the recipes.

sort_by

The column name to sort by (e.g., "rating", "prep_time").

ascending

Boolean; if TRUE, sorts in ascending order, else in descending order.

Value

A sorted data frame of recipes.

Examples

sort_recipes(data = recipes, sort_by = "rating", ascending = FALSE)
#> # A tibble: 6,503 × 10
#>    recipe_title      rating description cuisine course diet  prep_time cook_time
#>    <chr>              <dbl> <chr>       <chr>   <chr>  <chr>     <dbl>     <dbl>
#>  1 Savory Shrimps O…      5 Savory Shr… Indian  Appet… Non …        20         8
#>  2 Chilli Oil Recipe      5 This Chill… Asian   Side … Vege…        10        15
#>  3 Bathua Raita Rec…      5 Bathua Rai… North … Side … Diab…        10         5
#>  4 Roasted Vegetabl…      5 is a delic… Italia… Appet… Vege…        20        30
#>  5 Moroccan Chicken…      5 Moroccan C… African Main … Non …        20        45
#>  6 Cheese And Corn …      5 Tostados a… Mexican Dinner Vege…        10        20
#>  7 White Bean Pasta…      5 Pasta beco… Italia… Dinner Vege…        10        30
#>  8 Asian Chicken No…      5 is a comfo… Asian   Appet… High…        10        45
#>  9 Thandai Nectarin…      5 Thandai is… Fusion  Desse… Vege…        30        45
#> 10 Watermelon, Chen…      5 Watermelon… Contin… Appet… Vege…        25         0
#> # ℹ 6,493 more rows
#> # ℹ 2 more variables: ingredients <chr>, instructions <chr>