Get startedGet started for free

DT::datatable

Now let's customize our table.

This exercise is part of the course

Building Dashboards with flexdashboard

View Course

Exercise instructions

  • Eliminate the column of row numbers and add buttons to the table from the previous exercise.

Hands-on interactive exercise

Have a go at this exercise by completing this sample 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)\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\ndatatable(station_trips_df)\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"}
Edit and Run Code