Aan de slagGa gratis aan de slag

Create gauge

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

Deze oefening maakt deel uit van de cursus

Building Dashboards with flexdashboard

Cursus bekijken

Oefeninstructies

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

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

{"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"}
Code bewerken en uitvoeren