Skip to content

Instantly share code, notes, and snippets.

@njtierney
Created November 14, 2023 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save njtierney/aa289ed7fff1ed81ff023e88872bb719 to your computer and use it in GitHub Desktop.
Save njtierney/aa289ed7fff1ed81ff023e88872bb719 to your computer and use it in GitHub Desktop.
pct_resupply <- tibble::tribble(
~Section, ~Days, ~`Distance.(mi)`, ~`Total.(mi)`, ~Resupply,
"Campo to Mt. Laguna", 3L, 42.9, 42.9, "B",
"Mt. Laguna to Warner Springs", 4L, 66.6, 109.5, "B",
"Warner Springs to Idyllwild", 5L, 69.9, 179.4, "B",
"Idyllwild to Big Bear City", 6L, 95.6, 275, "B",
"Big Bear City to Wrightwood", 6L, 94.5, 369.5, "B",
"Wrightwood to Agua Dulce", 6L, 85, 454.5, "B",
"Agua Dulce to Tehachapi or Mojave", 6L, 112, 566.5, "B",
"Tehachapi to Kennedy Meadows", 8L, 135.5, 702.2, "M",
"Kennedy Meadows to Independence", 5L, 86.7, 788.9, "B",
"Independence to Tuolumne Meadows", 9L, 153.6, 942.5, "B",
"Tuolumne Meadows to South Lake Tahoe", 9L, 152, 1094.5, "B",
"South Lake Tahoe to Sierra City", 5L, 103, 1197.5, "B",
"Sierra City to Belden", 5L, 92, 1289.5, "B",
"Belden to Chester", 2L, 45.2, 1334.7, "B",
"Chester to Burney Falls State Park", 4L, 88.8, 1423.5, "M",
"Burney Falls State Park to Castella", 4L, 83.1, 1506.6, "B",
"Castella to Etna", 5L, 100, 1606.6, "B",
"Etna to Seiad Valley", 3L, 55.5, 1662.1, "B",
"Seiad Valley to Ashland", 3L, 63.9, 1726, "B",
"Ashland to Crater Lake Post Office", 5L, 103.3, 1829.3, "M",
"Crater Lake Post Office to Shelter Cove Resort", 4L, 83, 1912.3, "M",
"Shelter Cove Resort to Sisters", 5L, 89, 2001.3, "M",
"Sisters to Timberline Lodge", 5L, 106, 2107.3, "M",
"Timberline Lodge to Cascade Locks", 2L, 47.7, 2155, "B",
"Cascade Locks to White Pass", 7L, 148, 2303, "M",
"White Pass to Snoqualmie Pass", 5L, 99, 2402, "B",
"Snoqualmie Pass to Skykomish", 4L, 74, 2476, "M",
"Skykomish to Stehekin", 6L, 104.2, 2580.2, "M",
"Stehekin to Manning Park", 5L, 88.6, 2668.8, "Finished"
)
miles_to_km <- function(miles) round(miles * 1.609,1)
library(tidyverse)
pct_resupply %>%
janitor::clean_names() %>%
mutate(
across(
ends_with("mi"),
miles_to_km,
.names = "{.col}_km"
),
.after = total_mi
) %>%
rename(
distance_km = distance_mi_km,
total_km = total_mi_km
) %>%
relocate(
distance_km,
.after = distance_mi
) %>%
readr::write_csv("~/Downloads/resupply.csv")
c(7L,
7L,
7L,
7L,
6L,
6L,
6L,
8L,
5L,
9L,
9L,
5L,
5L,
2L,
4L,
4L,
5L,
3L,
3L,
5L,
4L,
5L,
5L,
2L,
7L,
5L,
4L,
6L,
5L) %>%
sum()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment