Skip to content

Instantly share code, notes, and snippets.

View nrkoehler's full-sized avatar
👁️‍🗨️
Focusing

Norbert Köhler nrkoehler

👁️‍🗨️
Focusing
View GitHub Profile
@dfalster
dfalster / addNewData.R
Last active February 19, 2023 00:29
The function addNewData.R modifies a data frame with a lookup table. This is useful where you want to supplement data loaded from file with other data, e.g. to add details, change treatment names, or similar. The function readNewData is also included. This function runs some checks on the new table to ensure it has correct variable names and val…
##' Modifies 'data' by adding new values supplied in newDataFileName
##'
##' newDataFileName is expected to have columns
##' c(lookupVariable,lookupValue,newVariable,newValue,source)
##'
##' Within the column 'newVariable', replace values that
##' match 'lookupValue' within column 'lookupVariable' with the value
##' newValue'. If 'lookupVariable' is NA, then replace *all* elements
##' of 'newVariable' with the value 'newValue'.
##'
@derekmcloughlin
derekmcloughlin / stats_equations.Rmd
Last active February 21, 2024 15:44
Useful Latex Equations used in R Markdown for Statistics
---
title: "Sample Equations used in Statistics"
output: html_document
---
### Summations
### Without Indices
$\sum x_{i}$
@EmilHvitfeldt
EmilHvitfeldt / horizontal.R
Created February 25, 2018 06:35
Horizontal annotations with ggrepel and ggplot2
library(tidyverse)
library(ggrepel)
set.seed(1234)
data <- tibble(x = seq_len(100),
y = cumsum(rnorm(100)))
anno_data <- data %>%
filter(x %% 25 == 10) %>%
library(isoband)
library(magick)
library(sf)
library(tidyverse)
# Adapted from Claus Wilke's code
# https://github.com/clauswilke/isoband
sf_from_image <- function(image, nbands) {
image_gray <- image %>% image_quantize(colorspace = "gray")
image_raster <- as.raster(image_gray)
@jthomasmock
jthomasmock / many_models.R
Created April 26, 2020 16:43
Take many variables, fit a model to them all at once, and visualize them all at once
library(tidyverse)
library(espnscrapeR)
library(broom)
library(glue)
# Get data from espnscrapeR
all_off <- 2000:2019 %>%
map_dfr(scrape_team_stats_nfl)
# Many LMs ----------------------------------------------------------------
@jlacko
jlacko / rstudio-init-script.R
Last active July 7, 2021 21:35
Init script for new RStudio installation, promoting best practices
# make certain jsonlite is available
if(!require(jsonlite, quietly = TRUE)) {
install.packages("jsonlite")
library(jsonlite)
}
# get the path to settings file
path <- if (Sys.info()[["sysname"]] == "Windows") {
paste0(Sys.getenv('APPDATA'), "\\RStudio\\rstudio-prefs.json")
} else {
library(tidyverse)
library(gt)
tuesdata <- tidytuesdayR::tt_load(2020, "36")
country_sel <- c("China", "India", "United States", "Indonesia", "Mexico", "Pakistan")
yield_data <- tuesdata$key_crop_yields %>%
janitor::clean_names() %>%
rename_with(~ str_remove(., "_tonnes_per_hectare")) %>%
select(entity:beans, -code) %>%
library(tidyverse)
library(broom)
library(latex2exp)
library(patchwork)
set.seed(1234)

logit_df <- tibble(x = seq(-5, 5, length.out = 100)) %>% 
    mutate(p = 1/(1 + exp(-x))) %>% 
    mutate(y = rbinom(n(), size = 1, prob = p))
@LilithWittmann
LilithWittmann / autobahn.md
Last active October 26, 2023 12:11
autobahn.md

Arbeitsamt Jobsuche API

Die Bundesagentur für Arbeit verfügt über die größte Datenbank für offene Stellen in Deutschland. Obwohl sie vollständig staatlich ist und es sich dabei um einen sehr spannenden Basisdatensatz handelt, mit dem viele Analysen möglich wären, bietet die Bundesagentur für Arbeit dafür bis heute keine offizielle API an.

Authentifizierung

Die Authentifizierung funktioniert per OAuth 2 Client Credentials mit JWTs. Die Client Credentials sind z.B. in der App hinterlegt:

ClientID: c003a37f-024f-462a-b36d-b001be4cd24a