Skip to content

Course Notes

Use this workspace to take notes, store code snippets, or build your own interactive cheatsheet! The datasets used in this course are available in the datasets folder.

# Import any packages you want to use here

Take Notes

Add notes here about the concepts you've learned and code cells with code you want to keep.

Chapter2: resizing graph

Add your notes here

# Add your code snippets here
---
title: "Bike Shares Daily"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
library(readr)
library(lubridate)
library(ggplot2)
library(tidyverse)

trips_df <- read_csv('https://assets.datacamp.com/production/course_6355/datasets/sanfran_bikeshare_joined_oneday.csv')
```

```{r static_plot}

trips_df %>%
  mutate(`Trip Duration (min)` = duration_sec / 60) %>%
  filter(`Trip Duration (min)` <= 60) %>%
  ggplot(aes(x = `Trip Duration (min)`)) +
  theme_bw() +
  geom_histogram(binwidth = 1) +
  ylab('# Trips')

```

Overview
===================================== 

Column {data-width=650}
-----------------------------------------------------------------------

### Origins

```{r}

```

Column {data-width=350}
-----------------------------------------------------------------------


### Trips by Start Time


### Trip Durations

chapter2: web-friendly visualisation

---
title: "Bike Shares Daily"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
library(readr)
library(lubridate)
library(ggplot2)
library(tidyverse)
library(plotly)

trips_df <- read_csv('https://assets.datacamp.com/production/course_6355/datasets/sanfran_bikeshare_joined_oneday.csv')
```


Overview
===================================== 

Column {data-width=650}
-----------------------------------------------------------------------

### Origins

```{r}

```

Column {data-width=350}
-----------------------------------------------------------------------


### Trips by Start Time


### Trip Durations

```{r}

duration_gg <- trips_df %>%
  mutate(`Trip Duration (min)` = duration_sec / 60) %>%
  filter(`Trip Duration (min)` <= 60) %>%
  ggplot(aes(x = `Trip Duration (min)`)) +
  theme_bw() +
  geom_histogram(binwidth = 1) +
  ylab('# Trips')

duration_gg

```

Chapter2: web-friendly2

---
title: "Bike Shares Daily"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
library(readr)
library(lubridate)
library(ggplot2)
library(tidyverse)
library(plotly)

trips_df <- read_csv('https://assets.datacamp.com/production/course_6355/datasets/sanfran_bikeshare_joined_oneday.csv')
```

Column 
-----------------------------------------------------------------------

### Station Usage

```{r}

station_df <- trips_df %>%
  select(start_station_name, end_station_name) %>%
  rename(Start = start_station_name, End = end_station_name) %>%
  pivot_longer(cols = Start:End, names_to = 'Usage', values_to = 'Station')

station_gg <- ggplot(station_df,
                     aes(x = Station, fill = Usage)) +
                     geom_bar(position = 'stack') +
                     theme_bw() +
                     ylab('Trips') +
                     xlab('') +
                     theme(axis.text.x = element_text(angle = 45, hjust = 1))
                
ggplotly(station_gg) 

```

Chapter2: Leaflet

---
title: "Bike Shares Daily"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
library(readr)
library(tidyverse)
library(leaflet)

stations_df <- read_csv('https://assets.datacamp.com/production/course_6355/datasets/stations_data.csv')
```


Column {data-width=650}
-----------------------------------------------------------------------

### Stations Map

```{r}
leaflet() %>%
addTiles() %>%
addMarkers(lng = stations_df$longitude, lat = stations_df$latitude)
```

Chapter3: value Box

---
title: "Bike Shares Daily"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
library(readr)
library(tidyverse)
library(lubridate)

trips_df <- read_csv('https://assets.datacamp.com/production/course_6355/datasets/sanfran_bikeshare_joined_oneday.csv')
```

Column {data-width=650}
-----------------------------------------------------------------------

### Origins


Column {data-width=350}
-----------------------------------------------------------------------

### Median Trip Length

```{r}

median_min <- median(trips_df$duration_sec / 60) %>% round(digits = 1)

valueBox(median_min,
    caption = "Median Trip Duration (Minutes)",
    icon = "fa-clock-o")
```

### % Short Trips


### Trips by Start Time


Chapter3: gauge