LoslegenKostenlos loslegen

Create gauge

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

Diese Übung ist Teil des Kurses

Building Dashboards with flexdashboard

Kurs anzeigen

Anleitung zur Übung

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

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

{"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 bearbeiten und ausführen