Web-friendly table
Now let's make the table in the last example more web-friendly.
Latihan ini adalah bagian dari kursus
Building Dashboards with flexdashboard
Petunjuk latihan
- Add a table in the Station Usage chart that contains the data in
station_trips_df, using thedatatable()function. - Knit and expand the HTML viewer to explore the resulting table. Try sorting on the Gap column, searching for all the Caltrain stations, and going from page to page.
Latihan interaktif praktis
Cobalah latihan ini dengan menyelesaikan kode contoh berikut.
{"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"}