LoslegenKostenlos starten

Color indicators

Let's imagine the bike share company has a goal to have two thirds of their trips under 10 minutes to maximize bike availability. We can indicate their success based on the gauge color.

Diese Übung ist Teil des Kurses

<Kurs>Building Dashboards with flexdashboard</Kurs>
Kurs ansehen

Übungsanweisungen

  • Add sectors to the "% Short Trips" gauge where 67 and up is success, 32 and below is danger, and warning is in between.

Interaktive praktische Ü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\ngauge(value = pct_short_trips,\n      min = 0,\n      max = 100)\n\n```\n\n### Trips by Start Time\n\n\n"}
Code bearbeiten und ausführen