Skip to content

Instantly share code, notes, and snippets.

@topepo
topepo / roc_shiny.R
Created December 5, 2019 21:02
shiny application for teaching ROC curves
library(shiny)
library(ggplot2)
library(dplyr)
library(yardstick)
theme_set(theme_bw())
n <- 1000
set.seed(124254)
@jcblum
jcblum / blogdown_relative_paths.md
Last active June 13, 2019 18:15
Ideas for using `fs` and `rstudioapi` to make relative paths less painful in `blogdown`

Some tools to help with relative paths, and a hasty napkin-sketch of things you might do with them

First, the tools

fs has fantastic tools for path computations!

# install.packages("fs")

# The stuff I'll use below... but there's tons that the package can do
# Things that need to be done just once
if (FALSE) {
  # We need the dev version of ggrepel
  devtools::install_github("slowkow/ggrepel")

  # Install Lato font on machine, then import it into extrafont library
  extrafont::font_import(pattern = "Lato")
}
library(tidyverse)
library(rvest)
url <- "https://en.wikipedia.org/wiki/The_Great_British_Bake_Off_(series_3)"
page <- read_html(url)
table <- page %>%
html_nodes("table.wikitable") %>%
.[[2]]
---
title: "World maps"
output:
html_document:
df_print: paged
---
```{r echo = FALSE, message = FALSE}
library(tidyverse)
library(sf)
@jnolis
jnolis / spread.R
Last active October 29, 2018 04:07
Example spread
library(tidyverse)
# here is a table that spreads the way you'd want (with two rows):
tribble(
~a, ~b, ~c,
"a", "x", 3,
"a", "y", 2,
"b", "x", 4,
"b", "y", 7
tap 'homebrew/fuse'
tap 'homebrew/dupes'
tap 'homebrew/cask'
tap 'homebrew/cask-fonts'
tap 'homebrew/cask-versions'
tap 'homebrew/cask-drivers'
cask_args appdir: '/Applications'
brew 'ack'
@stephlocke
stephlocke / scrape.R
Created July 8, 2018 11:41
Scrape and consolidate the year superheroes made their debut in comics
library(tidyverse)
library(rvest)
"https://en.wikipedia.org/wiki/List_of_superhero_debuts" %>%
read_html() %>%
html_nodes(xpath = "//*[@id='mw-content-text']/div/table") %>%
map(html_table, fill = TRUE) %>%
map_df( ~ mutate(., `Year Debuted` = as.character(`Year Debuted`))) %>%
mutate(`Char_Team` = coalesce(`Character / Team / Series`, `Character / Team`)) %>%
select(Char_Team, Year_Debut = `Year Debuted`) %>%
sample_id B1 B2 B3 reading_date ward service_line_material
2 8.1 10.8 2.8 aug-15 9 Unknown
4 1.1 BD BD aug-15 1 Copper
7 7.2 1.4 BD aug-15 9 Copper
8 40.6 9.7 6.1 aug-15 9 Lead
12 10.6 1.0 1.3 aug-15 9 Unknown
15 4.4 BD BD aug-15 9 Copper
16 24.4 8.8 4.3 aug-15 5 Galvanized
17 6.6 5.8 1.4 aug-15 2 Unknown
18 4.1 1.1 1.1 aug-15 7 Copper
---
title: "Untitled"
author: "Brandon Hurr"
date: "4/18/2018"
output:
beamer_presentation:
latex_engine: xelatex
---
```{r setup, include=FALSE}