Skip to content

Instantly share code, notes, and snippets.

@aammd
aammd / functions.r
Created November 12, 2015 20:32
A quick rewrite of Shaun Jackman's original `make` lesson, written for Rich Fitzjohn's `remake`
make_plot <- function(mydata){
qplot(Length, Freq, data=mydata)
}
# somewhat hackish solution to:
# https://twitter.com/EamonCaddigan/status/646759751242620928
# based mostly on copy/pasting from ggplot2 geom_violin source:
# https://github.com/hadley/ggplot2/blob/master/R/geom-violin.r
library(ggplot2)
library(dplyr)
"%||%" <- function(a, b) {

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

Pull Request Process

  1. Ensure any install or build dependencies are removed before the end of the layer when doing a
@lx-88
lx-88 / superscript in R ggplot2 axis label.R
Created September 8, 2015 05:50
Include a superscript in a ggplot2 axis label. Useful for a unit...
# use expression
# within expression, ~ represents a space
chanDensity_plot <- ggplot(data=chan_density_df, aes(x=site, y=density)) +
geom_bar(stat='identity') +
labs(x="Site", y=expression(Channel~Density~(km/km^2)), title='LIDAR-derived channel density')
@ramnathv
ramnathv / README.md
Last active December 30, 2015 10:40
NPR Viz Replication using ggplot2 and directlabels

Imgur

@zkamvar
zkamvar / znk_snippets.snippets
Last active July 12, 2016 13:04
Custom snippets that I use for Rstudio
# test that skeleton
snippet tt
test_that("${1:stuffworks}", {
${2:skip_on_cran()}
})
# add a header line
snippet hl
#==============================================================================#
${0}
@psychemedia
psychemedia / numbers2words.R
Created July 12, 2015 00:12
R function to convert numbers to words
#https://github.com/ateucher/useful_code/blob/master/R/numbers2words.r
numbers2words <- function(x){
## Function by John Fox found here:
## http://tolstoy.newcastle.edu.au/R/help/05/04/2715.html
## Tweaks by AJH to add commas and "and"
helper <- function(x){
digits <- rev(strsplit(as.character(x), "")[[1]])
nDigits <- length(digits)
if (nDigits == 1) as.vector(ones[digits])
#' ---
#' output:
#' html_document:
#' keep_md: TRUE
#' ---
#+ include = FALSE
library(dplyr)
#' Responses to [my
@somebox
somebox / osx-setup.sh
Last active December 11, 2021 13:05 — forked from foz/osx-setup.sh.md
Set up an OSX machine from zero to awesome. Uses Homebrew (and cask, fonts, etc). Focused on Ruby/Rails development, includes rvm, xquartz, editor fonts, sublime text, and many tools.
#!/bin/bash
# A script to set up a new mac. Uses bash, homebrew, etc.
# Focused for ruby/rails development. Includes many utilities and apps:
# - homebrew, rvm, node
# - quicklook plugins, terminal fonts
# - browsers: chrome, firefox
# - dev: iterm2, sublime text, postgres, chrome devtools, etc.
# - team: slack, dropbox, google drive, skype, etc