Static table
Let's imagine that your dashboard viewers need to see how many trips started and ended at each bikeshare station to manage balancing of bikes. We can provide this information in a simple table.
Este ejercicio forma parte del curso
Building Dashboards with flexdashboard
Instrucciones del ejercicio
- Add a table in the Station Usage chart that contains the data in
station_trips_df, using thekable()function. - Knit and expand the HTML viewer to explore the resulting table. Try scrolling down.
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
{"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)\nlibrary(knitr)\nlibrary(DT)\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### Station Usage\n\n```{r}\n\nstation_trips_df <- trips_df %>%\n select(start_station_name, end_station_name) %>%\n pivot_longer(cols = start_station_name:end_station_name, names_to = 'Type', values_to = 'Station') %>%\n group_by(Station, Type) %>%\n summarize(n_trips = n()) %>% \n mutate(Type = ifelse(Type == 'start_station_name', 'Trip Starts', 'Trip Ends')) %>%\n pivot_wider(names_from = 'Type', values_from = 'n_trips') %>%\n replace_na(list(`Trip Starts` = 0, `Trip Ends` = 0)) %>%\n mutate(Gap = `Trip Ends` - `Trip Starts`)\n\n```\n\n\nColumn {data-width=350}\n-----------------------------------------------------------------------\n\n### Median Trip Length\n\n\n### % Short Trips\n\n\n### Trips by Start Time\n\n\n"}