Data Description

The activities data set has the total daily totals for a Strava user’s cycling activities. The columns are:

  1. date: The YYYY-MM-DD date (will need to be converted to a date type object)
  2. trips: The number of activities recorded for that day
  3. distance: The total distance traveled that day, in kilometers
  4. moving_time: The time spent moving that day, in seconds
  5. max_speed: The fastest recorded speed that day, in kph
  6. elevation_gained: the total distance climbed uphill, in meters
  7. dirt_dist: the total distance traveled on gravel or dirt paths, in meters
## # A tibble: 153 × 7
##    date       trips distance moving_time max_speed elevation_gain dirt_dist
##    <chr>      <int>    <dbl>       <int>     <dbl>          <dbl>     <dbl>
##  1 2023-06-25     1     5.01        1343      6.82           36.1        0 
##  2 2023-06-27     2     9.26        2141      9.75           46.3      102.
##  3 2023-06-28     1    14.9         3599     15.4            28.5      833.
##  4 2023-06-29     1     7.41        1912      6.81           20.0      187.
##  5 2023-06-30     2    15.7         3912     29.4            49.9      287 
##  6 2023-07-01     1     3.52         797      9.00           24.9        0 
##  7 2023-07-02     2    11.8         2739      8.05           47.5      466.
##  8 2023-07-04     1    18.0         4019      7.69           41.7     3690.
##  9 2023-07-14     1    25.0         4676     23.7           157.       892.
## 10 2023-07-15     2    19.0         3992      7.71           34.0      236.
## # ℹ 143 more rows

Create the graph seen in Brightspace

This homework assignment only has one question: Create the graph seen in Brightspace

Important Notes:

You’ll need to use both activities and all_days data frames to form the data set to create the graph

kilometers (data) have been changed to miles (graph) and 1 km = 0.6 mi

meters (data) have changed to feet (graph) and 1 meter = 3.3 feet

seconds (data) have been changed to hours (graph) and 1 hour = 3600 seconds.

While not something you should always do, the missing values should be replaced with 0 since NA indicates no activities for that day and no activities -> 0 time, 0 distance, etc…

One column you’ll need to create is average_speed = distance/moving_time. Because there are days with no moving time, the fraction will divide by 0 and return NaN. Any days without any activities (trips = 0, distance = 0, and moving_time = 0) should record an average_speed of 0.

Create the data set needed for the graph in the code chunk below:

Create the graph in the code chunk below. You’ll only need to use geom_area() to create the line and shaded area below it. It is also the only geom you’ll need to add.

In facet_wrap(), include strip.position = 'left' to place the label for each graph on the left side of the plot. Make sure to include the theme() and scale_x_date() code in the code chunk so it matches the results!