Skip to content

Instantly share code, notes, and snippets.

View ateucher's full-sized avatar

Andy Teucher ateucher

View GitHub Profile
@Pakillo
Pakillo / git-github-tutorials.md
Last active July 8, 2023 13:51
Git & GitHub tutorials
@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 / ggplot_resources.md
Last active October 17, 2022 04:38
ggplot2: tutorials and complementary packages
@rmflight
rmflight / adv-r.md
Last active June 7, 2017 04:07
compiling @hadley books

In the shell:

git clone https://github.com/hadley/adv-r.git
gem install jekyll mime-types

In R:

@jcheng5
jcheng5 / ggbrush.R
Last active September 9, 2023 23:55
ggbrush
library(ggplot2)
library(shiny)
# Call ggbrush with a ggplot2 object, and the dimensions which
# should be brushed (try "xy" for scatter, "x" for histogram).
# The plot will show in RStudio Viewer or your web browser, and
# any observations selected by the user will be returned.
ggbrush <- function(plotExpr, direction = c("xy", "x", "y")) {
# See below for definition of dialogPage function
#' @export
coord_proj <- function(proj="+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs",
inverse = FALSE, degrees = TRUE,
ellps.default="sphere", xlim = NULL, ylim = NULL) {
try_require("proj4")
coord(
proj = proj,
inverse = inverse,
ellps.default = ellps.default,
degrees = degrees,
@hadley
hadley / beer.R
Last active September 10, 2015 16:49
bottles_of_beer <- function(i = 99) {
message("There are ", i, " bottles of beer on the wall, ", i, " bottles of beer.")
while(i > 0) {
tryCatch(
Sys.sleep(1),
interrupt = function(err) {
i <<- i - 1
if (i > 0) {
message(
"Take one down, pass it around, ", i,
@ateucher
ateucher / find_parens.R
Created October 16, 2015 21:50
Find matching parens in a string
find_matching_paren <- function(str, open_paren = "(") {
close_paren <- switch(open_paren, "(" = ")", "{" = "}", "[" = "]")
# Split string into single characters
str <- strsplit(str, "")[[1]]
## Find the first openening parenthesis in the string
start_pos <- grep(paste0("\\", open_paren), str)[1] + 1
counter <- 1
@emhart
emhart / prism_leaflet.R
Created October 29, 2015 05:36
Create javascript leaflet maps of prism data
library(devtools)
install_github("ropensci/prism")
library(leaflet)
library(raster)
library(prism)
## Set default path for raster files
options(prism.path = "~/prismtmp")
get_prism_normals(type="tmean",resolution = "4km",annual =T, keepZip=F)
@pramsey
pramsey / ccog-readinglist.md
Last active September 3, 2021 00:30
Canadian Council on Geomatics Reading List