Skip to content

Instantly share code, notes, and snippets.

library(egg)
library(gridExtra)
library(ggplot2)
library(grid)
d <- data.frame(x=runif(10*7),
y=runif(10*7),
f1 = gl(7,10),
f2 = gl(3, 30, 7*10))
@jnolis
jnolis / 3-legged-twitter-auth-lite.R
Last active August 7, 2021 19:30
Do 3-legged Twitter authentication for rtweet (lite version)
# _____ __ __
# |__ / / /__ ____ _____ ____ ____/ /
# /_ <______/ / _ \/ __ `/ __ `/ _ \/ __ /
# ___/ /_____/ / __/ /_/ / /_/ / __/ /_/ /
# /____/ /_/\___/\__, /\__, /\___/\__,_/
# /____//____/
# RTWEET + 3-LEGGED-AUTH DEMO (LITE)
# This code demonstrates how to do 3-legged authentication for Twitter
# using the {rtweet} package. Based heavily on code from Michael Kearney.
@emitanaka
emitanaka / collapseoutput.js
Created July 20, 2019 04:43
Collapsible Code Output for `xaringan`
<script>
(function() {
var divHTML = document.querySelectorAll(".details-open");
divHTML.forEach(function (el) {
var preNodes = el.getElementsByTagName("pre");
var outputNode = preNodes[1];
outputNode.outerHTML = "<details open class='output'><summary>Output</summary>" + outputNode.outerHTML + "</details>";
})
})();
(function() {
#' Conditionally apply expressions on a data object
#'
#' @param .data Input data
#' @param condition A logical value to determine whether to use .if or .else
#' @param .if Formula or function to apply to intput data when condition is TRUE
#' @param .else Formula or function to apply to intput data when condition is FALSE
#' @return Output of appropriate .if/.else call
#' @export
#' @importFrom rlang as_closure
do_if_else <- function(.data, condition, .if, .else = identity) {
library(dplyr)
do_if <- function(.data, condition, call){
if(condition){
.x <- .data
call_str <- call %>%
as.character %>%
.[2]
---
title: "Presentation Ninja"
subtitle: "⚔<br/>with xaringan"
author: "Yihui Xie"
date: "2016/12/12 (updated: `r Sys.Date()`)"
output:
xaringan::moon_reader:
lib_dir: libs
css:
- default
library(tidyverse)
library(sf)
library(scico)
# https://gis.utah.gov/data/boundaries/citycountystate/
counties <- st_read("data/Counties/Counties.shp")
# https://gis.utah.gov/data/society/schools-libraries/
libraries <- st_read("data/Libraries/Libraries.shp")
@djnavarro
djnavarro / bridge.R
Created September 2, 2018 08:19
bridge of eels animation
library(tidyverse)
library(e1071)
library(gganimate)
library(viridis)
ascii_bridge <- "
.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,1,1,1,1,1,1,1,1,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.
.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,1,1,1,1,.,1,.,.,.,.,1,.,1,1,1,1,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.
.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,1,1,1,1,.,.,.,.,1,.,.,.,.,1,.,.,.,.,1,1,1,1,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.
.,.,.,.,.,.,.,.,.,.,.,.,.,.,1,1,.,.,.,1,.,.,.,.,1,.,.,.,.,1,.,.,.,.,1,.,.,.,1,1,.,.,.,.,.,.,.,.,.,.,.,.,.,.
@HanjoStudy
HanjoStudy / useR2018.md
Last active November 10, 2023 02:07
useR2018 Material

I am looking forward to meeting you at the Tuesday AM (10th of July) tutorial session at useR2018!. We will be discussing a subject that I am very passionate about: Web Scraping!

The slides can be found here:

To ensure that we can be immediately productive on Tuesday morning, I would like you to get the following set up on your machines beforehand:

@ikashnitsky
ikashnitsky / colorcoded-map-population-structures.R
Last active February 5, 2020 09:28
Code to reproduce the RGB map of the population structure of NUTS-3 regions of Europe -- https://ikashnitsky.github.io/2017/colorcoded-map/
################################################################################
#
# ikashnitsky.github.io 2017-06-30
# Produce an RGB coded map of pop structures at NUTS-3 level
# Ilya Kashnitsky, [email protected]
#
################################################################################
# load required packages
library(tidyverse) # data manipulation and viz