Skip to content

Instantly share code, notes, and snippets.

View joethorley's full-sized avatar

Joe Thorley joethorley

View GitHub Profile
@dgrtwo
dgrtwo / dice-rolls.R
Created February 25, 2019 23:56
Animation of die rolls
# Code behind this tweet: https://twitter.com/drob/status/1100182329350336513
library(tidyverse)
library(gganimate)
# Setup
options(gganimate.nframes = 200)
set.seed(2019)
simulation <- tibble(roll = 1:10000) %>%
mutate(result = sample(6, n(), replace = TRUE)) %>%
@joethorley
joethorley / dprint.R
Last active January 10, 2017 18:49
print when debugging
dprint <- function(x, note = NULL, do = getOption("dprint.do", TRUE)) {
if (!do) return(invisible())
if (!is.null(note))
cat("\n**", note, "**\n")
cat("\n", deparse(substitute(x)), ": \n", sep = "")
print(x)
}
@lukas-h
lukas-h / license-badges.md
Last active May 9, 2024 08:26
Markdown License Badges for your Project

Markdown License badges

Collection of License badges for your Project's README file.
This list includes the most common open source and open data licenses.
Easily copy and paste the code under the badges into your Markdown files.

Notes

  • The badges do not fully replace the license informations for your projects, they are only emblems for the README, that the user can see the License at first glance.

Translations: (No guarantee that the translations are up-to-date)

@hadley
hadley / advise.md
Created February 13, 2015 21:32
Advise for teaching an R workshop

I think the two most important messages that people can get from a short course are:

a) the material is important and worthwhile to learn (even if it's challenging), and b) it's possible to learn it!

For those reasons, I usually start by diving as quickly as possible into visualisation. I think it's a bad idea to start by explicitly teaching programming concepts (like data structures), because the pay off isn't obvious. If you start with visualisation, the pay off is really obvious and people are more motivated to push past any initial teething problems. In stat405, I used to start with some very basic templates that got people up and running with scatterplots and histograms - they wouldn't necessary understand the code, but they'd know which bits could be varied for different effects.

Apart from visualisation, I think the two most important topics to cover are tidy data (i.e. http://www.jstatsoft.org/v59/i10/ + tidyr) and data manipulation (dplyr). These are both important for when people go off and apply

@Pakillo
Pakillo / word-character-count-Rstudio.md
Last active June 25, 2020 21:24
Count words and characters in Rstudio

As far as I know Rstudio does not count words or characters at the moment, which would be useful particularly when writing Rmarkdown.

This is a quick shortcut using word_count and character_count functions from qdap package. See below for two wrapper functions that simplify their use.

library("qdap")

Just select and copy the text to the clipboard and then run in the console:

@joethorley
joethorley / ext.R
Last active August 29, 2015 13:56
Wrappers to get, remove, replace, add and test file name extensions
library(tools)
library(assertthat)
#' @title Filename extension utilities
#'
#' @description Replaces, adds or removes (rm) extensions from filenames or test whether
#' filename has an extension or is a filename with a particular extension.
#' Functions are primarily wrappers
#' on the tools package functions \code{file_ext} and \code{file_path_sans_ext}.
#'
@jbryer
jbryer / package.R
Last active January 16, 2022 06:31
#' Simplified loading and installing of packages
#'
#' This is a wrapper to \code{\link{require}} and \code{\link{install.packages}}.
#' Specifically, this will first try to load the package(s) and if not found
#' it will install then load the packages. Additionally, if the
#' \code{update=TRUE} parameter is specified it will check the currently
#' installed package version with what is available on CRAN (or mirror) and
#' install the newer version.
#'
#' @param pkgs a character vector with the names of the packages to load.
@t-io
t-io / osx_install.sh
Last active October 22, 2023 13:04
Install most of my Apps with homebrew & cask
#!/bin/sh
echo Install all AppStore Apps at first!
# no solution to automate AppStore installs
read -p "Press any key to continue... " -n1 -s
echo '\n'
echo Install and Set San Francisco as System Font
ruby -e "$(curl -fsSL https://raw.github.com/wellsriley/YosemiteSanFranciscoFont/master/install)"
echo Install Homebrew, Postgres, wget and cask
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
@phette23
phette23 / update-repos.fish
Last active March 22, 2024 04:34
Shell script to run `git pull` inside all subdirectories which are git repositories. I keep a number of projects in a folder & this helps me avoid manually updating each.
#!/usr/bin/env fish
# similar script in Fish
# still under construction, need to quiet `git status` more effectively
function update -d 'Update git repo'
git stash --quiet
git pull
git stash apply --quiet
end
@serra
serra / README.md
Last active June 12, 2023 15:35 — forked from joelverhagen/README.md

This is a plugin meant for Jekyll.

Example use:

Easily embed a YouTube video. Just drop this file in your _plugins directory.

{% youtube oHg5SJYRHA0 %}