Skip to content

Instantly share code, notes, and snippets.

@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'
@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')
@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])
@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
library(shiny)
library(ggplot2)
ui <- basicPage(
plotOutput("plot1", brush = "plot_brush"),
actionButton("select", label="Select Data"),
actionButton("reset", label="Reset"),
verbatimTextOutput("info")
)
@artemklevtsov
artemklevtsov / .gitlab-ci.yml
Last active January 12, 2024 04:14
Testing R package with GitLab CI (with code coverage)
variables:
CODECOV_TOKEN: "CODECOV_TOKEN_STRING"
_R_CHECK_CRAN_INCOMING_: "false"
_R_CHECK_FORCE_SUGGESTS_: "true"
APT_PKGS: "libcurl4-openssl-dev libssh2-1-dev libssl-dev libxml2-dev zlib1g-dev git"
before_script:
- apt-get update
- apt-get install -y --no-install-recommends ${APT_PKGS}
- apt-get install -y --no-install-recommends qpdf pandoc pandoc-citeproc
library(ggplot2)
library(grid)
geom_point2 <- function(mapping = NULL, data = NULL,
stat = "identity", position = "identity",
...,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE) {
---
title: "Summarise and mutate multiple columns"
output: html_document
---
```{r, include = FALSE}
library(dplyr)
knitr::opts_hooks$set(
asciicast = rsciinema::asciicast_hook
)
library(purrr)
library(dplyr)
na_set <- function(x, p){
p <- as_mapper(p)
x[p(x)] <- NA
x
}
# or something like this using case_when
@stephlocke
stephlocke / Checklist.md
Last active May 25, 2018 19:01
Conference good practices according to Steph!
  • Have a Code of Conduct and a demonstrable commitment to diversity
    • The Code of Conduct must be prominently displayed
    • Sponsors and other third parties must adhere to the Code of Conduct
  • Provide a mechanism for low income attendees to get reduced prices and support where the event charges more than a day's income
  • Attendees encounter only non-defaulted opt-ins to marketing and future contact, especially from third parties
  • The data entrusted to the event is handled with due care and consideration
  • Diverse attendees' needs are considered and taken into consideration. Things like (but not limited to) large print agendas, gender neutral bathrooms, quiet rooms, family rooms, and prayer rooms are implemented to ensure a pleasant experience for all attendee
  • Volunteers and organisers should receive reduced or free entry to the event
  • New speakers are encouraged and offered extra support
  • The speaker selection process is performed in a way that reduces possible sources of bias