Skip to content

Instantly share code, notes, and snippets.

View sebastiansauer's full-sized avatar
🇺🇦
🇺🇦

Sebastian Sauer sebastiansauer

🇺🇦
🇺🇦
View GitHub Profile
@krassowski
krassowski / example_font_awesome.R
Created March 17, 2022 18:06
ggplot geom_font_awesome
library(ggplot2)
source('geom_font_awesome.R')
shapes_map = c(
setosa = 'car',
virginica = 'ban',
versicolor = 'star'
)
(
@acoppock
acoppock / gelman_and_hill_chapter_3.R
Created September 16, 2018 14:33
Gelman and Hill Chapter 3 Using ggplot and estimatr
# Gelman and Hill 2007: Chapter 3 Regression Examples
# Using ggplot and estimatr
rm(list = ls())
# Uncomment to install
# install.packages("ggplot2")
# install.packges("haven")
# install.pacakges("estimatr")
library(ggplot2)
@DarwinAwardWinner
DarwinAwardWinner / analyze_pkg_usage.R
Last active July 8, 2023 10:08
Script for finding loaded but unused packages in R scripts
#!/usr/bin/env Rscript
suppressPackageStartupMessages({
library(globals)
library(readr)
library(stringr)
library(rex)
library(magrittr)
library(rlang)
library(knitr)
# data from http://ec.europa.eu/eurostat/web/gisco/geodata/reference-data/population-distribution-demography/geostat
# Originally seen at http://spatial.ly/2014/08/population-lines/
# So, this blew up on both Reddit and Twitter. Two bugs fixed (southern Spain was a mess,
# and some countries where missing -- measure twice, submit once, damnit), and two silly superflous lines removed after
# @hadleywickham pointed that out. Also, switched from geom_segment to geom_line.
# The result of the code below can be seen at http://imgur.com/ob8c8ph
library(tidyverse)
@briandk
briandk / generate_package_citations.R
Created April 9, 2017 18:21
Wil Doane's system for automatically generating bibliography entries for the R packages you're using
# Early in the script
pkgs_pre_script <- try(devtools::loaded_packages(), silent = TRUE)
# Late in the script
pkgs_used_during_script <- try(devtools::loaded_packages(), silent = TRUE)
cat("* ")
print(citation(), style="text") # or Bibtex or LaTeX
@briandk
briandk / rmarkdown.yml
Created March 21, 2016 01:31
Default YAML block for RMarkdown Manuscripts
title: "[Title Goes Here]"
author: "[Blinded for Review]"
documentclass: "article"
output:
pdf_document:
keep_tex: true
number_sections: true
highlight: "tango"
toc: true
md_extensions: +implicit_figures +grid_tables +fenced_code_blocks +fenced_code_attributes
@daattali
daattali / linkedin.R
Created March 5, 2016 11:11
Scraping Twitter and LinkedIn info in R
# Get a person's name, location, summary, # of connections, and skills & endorsements from LinkedIn
# URL of the LinkedIn page
user_url <- "https://www.linkedin.com/in/daattali"
# since the information isn't available without being logged in, the web
# scraper needs to log in. Provide your LinkedIn user/pw here (this isn't stored
# anywhere as you can see, it's just used to log in during the scrape session)
username <- "yourusername"
password <- "yourpassword"
@chrissimpkins
chrissimpkins / gist:5bf5686bae86b8129bee
Last active March 6, 2023 00:10
Atom Editor Cheat Sheet: macOS

Use these rapid keyboard shortcuts to control the GitHub Atom text editor on macOS.

Key to the Keys

  • ⌘ : Command key
  • ⌃ : Control key
  • ⌫ : Delete key
  • ← : Left arrow key
  • → : Right arrow key
  • ↑ : Up arrow key
@jennybc
jennybc / reverse-categorical-axis-ggplot2.r
Created October 10, 2014 01:06
Reverse the order of a categorical axis in ggplot2
scale_x_discrete(limits = rev(levels(the_factor)))
@lmullen
lmullen / Makefile
Last active February 25, 2023 21:14
PDF slides and handouts using Pandoc and Beamer
SLIDES := $(patsubst %.md,%.md.slides.pdf,$(wildcard *.md))
HANDOUTS := $(patsubst %.md,%.md.handout.pdf,$(wildcard *.md))
all : $(SLIDES) $(HANDOUTS)
%.md.slides.pdf : %.md
pandoc $^ -t beamer --slide-level 2 -o $@
%.md.handout.pdf : %.md
pandoc $^ -t beamer --slide-level 2 -V handout -o $@