Skip to content

Instantly share code, notes, and snippets.

👨‍💻
just typing R code...

Garrick Aden-Buie gadenbuie

View GitHub Profile
View mueller-report_top-25-words.R
library(tidyverse)
library(tidytext)
mueller_report <- read_csv("mueller_report.csv")
mueller_report_tidy <-
mueller_report %>%
tidytext::unnest_tokens(word, text)
mueller_report_tidy %>%
View bootstrap_docker.sh
#!/bin/bash
# https://docs.docker.com/install/linux/docker-ce/debian/
# Get certificates
echo "Installing certificates..."
sudo apt-get update
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
View tidyr_spread_example.md
library(tidyverse)

spread_var <- function(df, varname) {
  varname <- rlang::enquo(varname)
  spread(df, key = !!varname, count)
}

head(tidyr::table2)
#> # A tibble: 6 x 4
View git_outta_here.sh
#!/bin/bash
is_inside_git_repo() {
[ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1
}
has_origin_remote() {
git remote get-url origin > /dev/null 2>&1
}
View everycolorbot_tweets.R
library(tidyverse)
library(rtweet)
tweets <- NULL
keep_going <- TRUE
i <- 1
while (keep_going && i <= 10) {
cat("\n", i, "...", sep = "")
tweets.this <- get_timeline(
"everycolorbot",
@gadenbuie
gadenbuie / app.R
Last active Jan 22, 2019
Tweet embed example
View app.R
library(shiny)
library(dplyr)
library(rtweet)
tweets <- search_tweets("#rstats", n = 5, include_rts = FALSE)
# https://github.com/mkearney/rtweet/pull/305/files
tweet_embed <- function(screen_name,status_id,...){
stem <- 'https://publish.twitter.com/oembed'
@gadenbuie
gadenbuie / rjdbc_dbplyr_example.R
Last active Dec 26, 2018
RJDBC example using ojdb8.jar and dbplyr
View rjdbc_dbplyr_example.R
# Connect Via RJDBC -------------------------------------------------------
library(RJDBC)
drv <- JDBC("oracle.jdbc.OracleDriver", classPath="~/import/instantclient_12_2/ojdbc8.jar")
con <- dbConnect(drv,"jdbc:oracle:thin:@server:1521:database",
rstudioapi::askForSecret("Username"),
rstudioapi::askForSecret("Database Password"))
dbGetQuery(con,"select count(*) from schema.table")
# Setup dplyr and dbplyr to work with RJDBC -------------------------------
@gadenbuie
gadenbuie / pre-commit
Created Dec 18, 2018 — forked from jeroenjanssens/pre-commit
Script that tests your #rstats code before committing to git. When you have failed tests the commit will be aborted. Requires the devtools, testthat, and purrr packages. Name this script `pre-commit`, make it executable, and place it in the .git/hooks subdirectory of your git repository.
View pre-commit
#!/usr/bin/env RScript
messages <- purrr::map_chr(devtools::test(),
list("results", 1, "message"))
q("no", status = sum(messages != "success"))
@gadenbuie
gadenbuie / get_my_github_stars.R
Last active Dec 18, 2018
Get My Starred GitHub Repos
View get_my_github_stars.R
if (!requireNamespace("gh", quietly = TRUE)) {
install.packages("gh")
}
if (!requireNamespace("roomba", quietly = TRUE)) {
library(devtools)
install_github("ropenscilabs/roomba")
}
library(dplyr)
@gadenbuie
gadenbuie / breaks_tutorial.Rmd
Last active Nov 30, 2018 — forked from EvaMaeRey/breaks_tutorial.Rmd
ggplot dplyr reveal breaking
View breaks_tutorial.Rmd
---
title: "ggplot tutorial"
subtitle: "with Emi Tanaka's kunoichi + ninjutsu theme"
author: "<br><br>Gina Reynolds"
date: "<br>2018/09/16"
output:
xaringan::moon_reader:
chakra: libs/remark-latest.min.js
lib_dir: libs
css: ["kunoichi", "ninjutsu"]
You can’t perform that action at this time.