CommencerCommencer gratuitement

Linking

Let's link the average trip duration value box to a page with more detail about trip durations.

Cet exercice fait partie du cours

Building Dashboards with flexdashboard

Afficher le cours

Instructions

  • Link the "Median Trip Length" value box to the Trip Duration page.
  • Knit and expand the HTML viewer, then try the link.

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)\nlibrary(plotly)\n\ntrips_df <- read_csv('https://assets.datacamp.com/production/course_6355/datasets/sanfran_bikeshare_joined_oneday.csv')\n```\n\nOverview\n====================================================\n\nColumn {data-width=650}\n-----------------------------------------------------------------------\n\n### Origins\n\n\nColumn {data-width=350}\n-----------------------------------------------------------------------\n\n### Median Trip Length\n\n```{r}\n\nmedian_min <- median(trips_df$duration_sec / 60) %>% round(digits = 1)\n\nvalueBox(median_min, \n         caption = 'Median Trip Duration (Minutes)', \n         icon = 'fa-clock-o')\n\n\n```\n\n### % Short Trips\n\n\n### Trips by Start Time\n\n\nTrip Duration\n====================================================\n\n### Trip Durations\n\n```{r}\n\nduration_plot <- trips_df %>%\n  mutate(`Trip Duration (min)` = duration_sec / 60) %>%\n  ggplot(aes(x = `Trip Duration (min)`)) +\n  theme_bw() +\n  geom_histogram(binwidth = 1) +\n  ylab('# Trips')\n\nduration_plot %>% ggplotly()\n\n```\n\n\n"}
Modifier et exécuter le code