Skip to content

Instantly share code, notes, and snippets.

@benmarwick
benmarwick / final-grade-calculations-488.R
Last active March 24, 2025 21:42
Final grade calculations from a Canvas gradebook that uses an additive grading policy
## Introduction
# This code will take grades on the Canvas gradebook, and add up the individual
# assignments to get a final grade, according to the policy for the class, in this
# case, here https://docs.google.com/spreadsheets/d/1-6f7mpgStojP4Gb3mk2PSwupGY2MiSrnIDD_KlxxEzk/edit?gid=874302185#gid=874302185
## Get the Canvas gradebook
# Go to the Canvas course page, go to the gradebook for that
# course, click 'Actions' then 'Export'. That will download a CSV file to
@benmarwick
benmarwick / prepare-radiocarbon-data-for-analyses-signbase.R
Last active November 16, 2024 21:52
Simple tasks with the SignBase dataset
library(tidyverse)
library(rcarbon)
signbase <- read_csv("signBase_Version1.0.csv")
# clean up and separate the data in the radiocarbon age columns
# so we can use it for plotting and analyses. This will generate some
# warnings, that's ok, nothing to worry about
signbase_years <-
signbase %>%
@benmarwick
benmarwick / gist:9778b094e95ee6f06d2db6e1831cc225
Created October 25, 2024 19:01
Take output from rcarbon::calibrate and plot with ggridges::geom_ridgeline
# Load required libraries
library(rcarbon)
library(ggplot2)
library(ggridges)
library(dplyr)
# Step 1: Calibrate dates
# Example data: replace with your actual radiocarbon dates and errors
dates <- c(4500, 4800, 5000) # Replace with your dates
errors <- c(30, 50, 100) # Replace with your errors
@benmarwick
benmarwick / gist:da75e66d8a8e989ba0ff4f19e58c54e4
Created October 24, 2024 04:17
what is the correct boxplot for this histogram?
data <- tibble( x = c(
# Peak 1 (around 0-2)
rep(1, 50), rep(2, 30), rep(3, 20),
# Dip (middle values)
rep(4, 10), rep(5, 8), rep(6, 8), rep(7, 10),
# Peak 2 (around 10-12)
rep(8, 20), rep(9, 30), rep(10, 50)
))
@benmarwick
benmarwick / gist:d0789be8014bb8dd079dd8c57cc587ea
Created April 12, 2024 05:54
Get data from the SOTA api to plot how many activations have been logged in each region of an association
library(rvest)
library(httr)
library(tidyverse)
# get list of regions in the W7W association
# via API
sota_regions_w7w <- "https://api2.sota.org.uk/api/associations/w7w"
r <- GET(sota_regions_w7w)
dat <-
jsonlite::fromJSON(content(r, as = "text")) %>%
@benmarwick
benmarwick / computing-sota-az-boundaries.R
Last active March 21, 2025 00:14
Compute polygons for SOTA activation zone boundaries for the W7W Association
library(raster)
library(terra)
library(tidyterra)
library(ggplot2)
library(sf)
library(tidyverse)
library(ggrepel)
library(ggspatial)
# get all summits via the GeoJSON download
@benmarwick
benmarwick / magnetic-susceptibility-data.R
Last active February 8, 2024 23:23
Exploring the magnetic susceptibility data from Boomplas
library(tidyverse) # you may need to install.packages("tidyverse") in the console
library(googlesheets4) # ditto
# change to your own UW email
gs4_auth("bmarwick@uw.edu")
# Get our google sheet of information about the location of each point
ms_data <-
read_sheet("https://docs.google.com/spreadsheets/d/1rDyfJQ6OnWJktIWMZfnLe8YRtCiW1PVrP9nKW1kERN4/edit?pli=1#gid=0")
@benmarwick
benmarwick / gist:44959d24ef6e53c86d3bd8aed83dffd5
Created January 18, 2024 07:57
Archaeology job ads from Archaeology Jobs Wiki
library(tidyverse)
base_url <- "http://academicjobs.wikia.com/wiki/Archaeology_Jobs_"
# starts at 2010-2011
years <- map_chr(2010:2019, ~str_glue('{.x}-{.x +1}'))
# though it seems to start at 2007-8: https://academicjobs.fandom.com/wiki/Archaeology_07-08
urls_for_each_year <- str_glue('{base_url}{years}')
@benmarwick
benmarwick / archy-course-schedule-overlaps.qmd
Last active February 7, 2024 17:03
ARCHY course time overlaps
---
title: "AY24-25 ARCHY course time overlaps"
format: html
execute:
echo: false
warning: false
self-contained: true
---
@benmarwick
benmarwick / gist:2237a297a33c8cb26053a526a192333e
Last active November 4, 2023 08:17
What time of the day do people post their SOTA spots?
library(httr2)
library(tidyverse)
library(sf)
library(lutz)
library(hms)
req <- request("https://api2.sota.org.uk/api/")
# get associations so we can get their time zones via lat-long
resp <- req %>%