Skip to content

Instantly share code, notes, and snippets.

View sschmutz's full-sized avatar

Stefan Schmutz sschmutz

View GitHub Profile
@sschmutz
sschmutz / baRcodeR_example.R
Created July 5, 2022 09:02
add a column containing a barcode
library(tidyverse)
library(baRcodeR) # using custom_create_PDF()
library(pdftools) # using pdf_convert()
library(gt)
library(gtExtras) # using gt_img_rows()
# create example list of numbers to translate to barcodes
samples <- tibble(nr = c("1000000001", "1000000002", "1000000003"))
@sschmutz
sschmutz / map_switzerland.R
Last active January 25, 2019 21:56
get data and plot map of Switzerland on a canton level
# load packages -----------------------------------------------------------
library(here)
library(sf)
library(ggplot2)
# download and read map data ----------------------------------------------
url_gadm <- "https://biogeo.ucdavis.edu/data/gadm3.6/shp/gadm36_CHE_shp.zip"
download.file(url = url_gadm,
destfile = here("gadm36_CHE_shp.zip"))
@sschmutz
sschmutz / 538_santa.R
Created January 3, 2019 21:57
538 Riddler Express - helping Santa
library(tidyverse)
# define amount of trials for the Monte Carlo Simulation
trial_n <- 1e5
order <- NULL
n_smaller <- NULL
# generate random order for each trial
for (trial in 1:trial_n) {
set.seed(181231 + trial)
library(tidyverse)
# define dimensions
width <- 0.5
height <- 16.5
spike <- 2
# create vectors for polygon
i <- rep(1:30, each = 6)
x_pol <- rep(0.5 * width * c(-1, 1, 1, 0, -1, -1), 30)
@sschmutz
sschmutz / qpcr_animation.R
Created December 7, 2018 18:46
animate qPCR data
library(googlesheets)
library(dplyr)
library(readr)
library(ggplot2)
library(gganimate)
# Sharing Link of Google Sheet
qpcr_data_url <-
"https://docs.google.com/spreadsheets/d/1iJSVC2JgcSm1fYTJmTBwpqBJKhfhXQpzdfN6ktCfib8/edit?usp=sharing"