Skip to content

Instantly share code, notes, and snippets.

@cwickham
cwickham / snippet.txt
Last active October 23, 2025 22:48
RStudio snippet to generate a random seed
snippet seed
set.seed(`r sample(0:999999, 1)`)
@cwickham
cwickham / r.json
Created October 23, 2025 22:10
Snippet to set random seed in Positron (or VS Code)
{
"Set seed": {
"prefix": "seed",
"body": "set.seed($RANDOM)",
"description": "Set the seed for random number generation"
}
}
@cwickham
cwickham / .gistr
Created November 16, 2022 21:13
R objects for ST499/599 final
gistr
@cwickham
cwickham / final_r_objects.rda
Created November 16, 2022 20:56
R objects for ST499/599 final
RDX3
X
data.frame
@cwickham
cwickham / 00_bind_rows.Rmd
Last active November 26, 2018 21:36
Example of combining `bind_rows()` with `map()` and `read_csv()`
---
title: Example of combining `bind_rows()` with `map()` and `read_csv()`
output: github_document
---
```{r}
library(tidyverse)
```
If you have some data files with a similar structure:
@cwickham
cwickham / .block
Last active November 7, 2018 21:37 — forked from jakevdp/.block
Multi-Value Tooltip in Vega-Lite
license: MIT
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://cdn.jsdelivr.net/npm/vega@4"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-embed@3"></script>
</head>
<body>
<div id="vis"></div>
@cwickham
cwickham / read_hurricanes.R
Last active August 16, 2019 13:49
A line by line stye of reading in the hurricane data
library(tidyverse)
library(xml2)
url <- "http://www.aoml.noaa.gov/hrd/hurdat/hurdat2-nepac.html"
# Import ------------------------------------------------------------------
hurricanes <- read_html(url) %>%
xml_find_first(".//pre") %>%
xml_text() %>%
@cwickham
cwickham / hurricanes.R
Created July 30, 2018 13:17
Import messy hurricane data
library(tidyverse)
library(xml2)
url <- "http://www.aoml.noaa.gov/hrd/hurdat/hurdat2-nepac.html"
# Column names ------------------------------------------------------------
# From: http://www.aoml.noaa.gov/hrd/hurdat/newhurdat-format.pdf
# for the data lines
wind_vars <- cross_df(list(
1 2
3 4