Skip to content

Instantly share code, notes, and snippets.

View z3tt's full-sized avatar
👨‍💻
Coding at home

Cédric Scherer z3tt

👨‍💻
Coding at home
View GitHub Profile
# =======================================
# = Enhancements to data tidying =
# = Hadley Wickham =
# = https://rstd.io/tidyhancements-2019 =
# =======================================
# What is tidy data? ----------------------------------------------------------
# 1. Each column is a variable.
# 2. Each row is an observation.
# 3. Each cell is a value.
@mschnetzer
mschnetzer / gerwealth.R
Last active April 9, 2020 12:21
Wenn Deutschland so verteilt wäre wie Vermögen (https://twitter.com/matschnetzer/status/1178930993186693121)
library(tidyverse)
library(msthemes)
library(sf)
# GeoJSON: http://opendatalab.de/projects/geojson-utilities/
geodat <- st_read("landkreise_simplify200.geojson", quiet=TRUE, stringsAsFactors=FALSE) %>%
mutate(
center = map(geometry, st_centroid),
centercoord = map(center, st_coordinates),
# License: Apache 2.0
# A straightforward translation of the Python code:
turbo_colormap_data <- matrix(
c(
c(0.18995, 0.07176, 0.23217),
c(0.19483, 0.08339, 0.26149),
c(0.19956, 0.09498, 0.29024),
c(0.20415, 0.10652, 0.31844),
#####################################################
#####################################################
### R Script for Metamodeling and Rule Extraction ###
#####################################################
#####################################################
#############################
### Step I: Load Packages ###
#############################
library(tidyverse)
library(lubridate)
library(scales)
df <- tibble(
date = seq.Date(from=ymd("2019-01-01"),to=ymd("2019-12-31"),by="day"),
wkdy = wday(date,label=T),
mo = month(date,label=T),
mo.num = month(date,label=F),
day = day(date)
library(ggplot2)
# dput(ls(pattern = "theme",package:ggplot2))
defaults <- c("theme_bw", "theme_classic", "theme_dark",
"theme_grey", "theme_light", "theme_linedraw",
"theme_minimal", "theme_void")
library(ggthemes)
# dput(ls(pattern = "theme",package:ggthemes))
addons <- c("theme_base", "theme_calc", "theme_economist",
"theme_economist_white", "theme_excel", "theme_few", "theme_fivethirtyeight",
"theme_foundation", "theme_gdocs", "theme_hc", "theme_igray",