CommencerCommencer gratuitement

Create gauge

Let's add a gauge to our dashboard to show the percentage of trips that are shorter than 10 minutes.

Cet exercice fait partie du cours

Building Dashboards with flexdashboard

Afficher le cours

Instructions

  • Add a gauge to the "% Short Trips" chart, displaying the value of pct_short_trips.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

{"my_document.Rmd":"---\ntitle: \"Bike Shares Daily\"\noutput: \n  flexdashboard::flex_dashboard:\n    orientation: columns\n    vertical_layout: fill\n---\n\n```{r setup, include=FALSE}\nlibrary(flexdashboard)\nlibrary(readr)\nlibrary(tidyverse)\nlibrary(lubridate)\n\ntrips_df <- read_csv('https://assets.datacamp.com/production/course_6355/datasets/sanfran_bikeshare_joined_oneday.csv')\n```\n\nColumn {data-width=650}\n-----------------------------------------------------------------------\n\n### Origins\n\n\nColumn {data-width=350}\n-----------------------------------------------------------------------\n\n### Median Trip Length\n\n\n### % Short Trips\n\n```{r}\n\nnum_trips <- nrow(trips_df)\nshort_trips <- sum(trips_df$duration_sec < 600) # under 10 min\npct_short_trips <- round(100 * short_trips / num_trips, 0)\n\n___(value = ___,\n      min = ___,\n      max = ___)\n```\n\n### Trips by Start Time\n\n\n"}
Modifier et exécuter le code