Skip to content

Instantly share code, notes, and snippets.

library(shiny)
library(ggplot2)
ui <- basicPage(
plotOutput("plot1", brush = "plot_brush"),
actionButton("select", label="Select Data"),
actionButton("reset", label="Reset"),
verbatimTextOutput("info")
)
@javierluraschi
javierluraschi / importing-modern-data-into-r
Last active August 16, 2017 05:19
Importing Modern Data - useR 2016
---
title: "Importing Modern Data into R"
author: Javier Luraschi
date: June 29, 2016
output: revealjs::revealjs_presentation
---
## Overview
* Importing Data
@thomasp85
thomasp85 / Histogram_animation.R
Last active December 17, 2021 11:20
An example of animating the build up of a histogram with dropping balls using tweenr, gganimate and ggplot2
library(tweenr) # Available on CRAN
library(ggforce) # Install from thomasp85/ggforce
library(gganimate) # Install from dgrtwo/gganimate
set.seed(2)
x <- sample(9,20, prob=c(1,2,3,4,5,4,3,2,1), replace=T)
df <- data.frame(x = x, y = 15)
dfs <- list(df)
for(i in seq_len(nrow(df))) {
dftemp <- tail(dfs, 1)
dftemp[[1]]$y[i] <- sum(dftemp[[1]]$x[seq_len(i)] == dftemp[[1]]$x[i])
@abresler
abresler / exploding_boxplot_test
Last active February 1, 2017 14:35
Expoding Boxplot Function & nbastatR test use case
# load_packages -----------------------------------------------------------
packages <-
c('nbastatR', #devtools::install_github("abresler/nbastatR")
'explodingboxplotR', #devtools::install_github("timelyportfolio/explodingboxplotR")
'ggplot2',
'dplyr',
'purrr',
'magrittr')
@dthyresson
dthyresson / stattleship-api-cam-newton-td-feats.rb
Last active December 10, 2015 23:45
Example of fetching Cam New Football TD Feats from the Stattleship API in Ruby
#!/bin/ruby
require 'awesome_print'
require 'csv'
require 'dotenv'
require 'httparty'
require 'hashie'
require 'highline'
require 'link_header'
@tcash21
tcash21 / README.md
Last active December 9, 2015 01:17 — forked from Btibert3/README.md
Testing stattleship, weird error

About

Updated the queryAPI and created a new function, stattle that wraps it and makes walking easier. jsonlite is great, but I started to bump into some issues with dplyr::bind_rows. Right now these two functions play nice together, but needs to be further tested.

Load/Install

## source the functions
devtools::source_url('https://gist.githubusercontent.com/tcash21/44667f7b8578cc8e061e/raw/fdac84a0a445e448427cc3557e8c9393ce1fa470/queryAPI.r')
@gluc
gluc / Desc_JSON_to_df.md
Last active June 19, 2023 02:32
Convert a complex JSON to an R data.frame

This gist shows how to convert a nested JSON file to an R data.frame. To do this, it uses jsonlite and data.tree.

The gist contains two examples: one is a bit simpler, the second one a bit more advanced.

Example 1

In the first example, we download all the repos from Hadley Wickham's Github account from https://api.github.com/users/hadley/repos . This JSON contains a nested owner object. The code shows how to convert that in a flat data.frame in three statements:

  1. line 5: download
  2. line 8: convert to data.tree
@bryangoodrich
bryangoodrich / TwitterTopics.r
Last active September 18, 2024 20:43
Twitter Topic Modeling Using R
# Twitter Topic Modeling Using R
# Author: Bryan Goodrich
# Date Created: February 13, 2015
# Last Modified: April 3, 2015
#
# Use twitteR API to query Twitter, parse the search result, and
# perform a series of topic models for identifying potentially
# useful topics from your query content. This has applications for
# social media, research, or general curiosity
#
@32bitkid
32bitkid / tufteize-codepen.less
Last active April 7, 2018 15:17
Tufte style link/citations/asides for codepen.io blog posts.
.tufteize(@gutter, @gap) {
> p { margin-right: @gutter + @gap; }
.newthought { font-variant: small-caps; }
p>strong,
p>a:not([href^='#'])::before,
p>a[href^='#'] + * {
width: @gutter;
margin-right: -(@gutter + @gap);
@jennybc
jennybc / 2014-10-12_stop-working-directory-insanity.md
Last active February 19, 2025 22:20
Stop the working directory insanity

There are packages for this now!

2017-08-03: Since I wrote this in 2014, the universe, specifically Kirill Müller (https://github.com/krlmlr), has provided better solutions to this problem. I now recommend that you use one of these two packages:

  • rprojroot: This is the main package with functions to help you express paths in a way that will "just work" when developing interactively in an RStudio Project and when you render your file.
  • here: A lightweight wrapper around rprojroot that anticipates the most likely scenario: you want to write paths relative to the top-level directory, defined as an RStudio project or Git repo. TRY THIS FIRST.

I love these packages so much I wrote an ode to here.

I use these packages now instead of what I describe below. I'll leave this gist up for historical interest. 😆