Skip to content

Instantly share code, notes, and snippets.

View richgillin's full-sized avatar
💭
Ready

Rich Gillin richgillin

💭
Ready
  • RStats.IO
  • Anchorage Alaska
  • 21:11 (UTC -08:00)
View GitHub Profile
@bobthecat
bobthecat / r-tutorial.r
Created August 15, 2012 15:41
R tutorial
### R code from vignette source 'Presentation.Rnw'
### Encoding: UTF-8
###################################################
### code chunk number 1: init
###################################################
options(width=60)
###################################################
@dsparks
dsparks / Heatmap.R
Last active August 19, 2022 06:54
ggplot2 heatmap with "spectral" palette
doInstall <- TRUE # Change to FALSE if you don't want packages installed.
toInstall <- c("ggplot2", "reshape2", "RColorBrewer")
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
# Generate a random matrix
# This can be any type of numeric matrix,
# though we often see heatmaps of square correlation matrices.
nRow <- 9
nCol <- 16
library(ggplot2)
library(ggmap)
# blue bottle coffee shops in SF area
latitude <- c(37.782375,37.795933,37.776327,37.762033,37.795966,37.785936)
longitude <- c(-122.407567,-122.273128,-122.42328,-122.411603,-122.394025,-122.400761)
df2 <- data.frame(longitude=longitude,latitude=latitude)
# df to make map title on the water
dflabels <- data.frame(longitude=-122.678,
@stephenturner
stephenturner / .Rprofile.r
Last active July 19, 2021 22:05
My .Rprofile
## See http://gettinggeneticsdone.blogspot.com/2013/06/customize-rprofile.html
## Load packages
library(BiocInstaller)
## Don't show those silly significanct stars
options(show.signif.stars=FALSE)
## Do you want to automatically convert strings to factor variables in a data.frame?
## WARNING!!! This makes your code less portable/reproducible.
@hadley
hadley / curriculum.md
Created September 27, 2013 20:24
My first stab at a basic R programming curriculum. I think teaching just these topics without overall motivating examples would be extremely boring, but if you're a self-taught R user, this might be useful to help spot your gaps.

Notes:

  • I've tried to break up in to separate pieces, but it's not always possible: e.g. knowledge of data structures and subsetting are tidy intertwined.

  • Level of Bloom's taxonomy listed in square brackets, e.g. http://bit.ly/15gqPEx. Few categories currently assess components higher in the taxonomy.

Programming R curriculum

Data structures

# Data latest polls
polls = NULL
polls <- data.frame( rbind(
Opinium = c(43, 47, 1156),
Survation = c(44, 48, 1000),
ICM = c(41, 45, 1175)
))
# set up for decimals
polls[, 1:2] <- polls[, 1:2]/100
@johnmyleswhite
johnmyleswhite / indexing.R
Created September 18, 2014 05:32
R indexing showcases all possible design theories
> v <- c(1, 2, 3, 4)
> v[1]
[1] 1
> v[4]
[1] 4
> v[0]
numeric(0)
> v[5]
[1] NA
> v[-1]
@jetsonhacks
jetsonhacks / jetson_kernel_install.md
Last active January 14, 2023 18:37 — forked from tstellanova/jetson_kernel_install.md
Install Grinch Linux4Tegra (L4T) version 19.3.6 for NVIDIA Jetson TK1

For this process you will need:

  • A host desktop or laptop computer running Ubuntu Linux 12.04. This may be a VM, I've used VirtualBox.
  • Micro USB cable provided with the Jetson TK1 kit
  • Jetson TK1 and power supply
  • Optional: DB9 null modem cable if you want to use the serial console during boot
  1. On your host computer open a Terminal, then create a directory to operate from, and switch to it. As an example:
mkdir ~/Grinch
cd ~/Grinch
@jennybc
jennybc / 2014-10-12_stop-working-directory-insanity.md
Last active September 23, 2022 04:43
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. 😆

@jmcastagnetto
jmcastagnetto / nist-beacon-response.R
Last active August 29, 2015 14:12
A simple and naive example of using the NIST Randomness Beacon in R (https://beacon.nist.gov/home)
require(RCurl)
require(XML)
# Let's make a special class
NISTBeaconResponse <- function (ts) {
if(!is.integer(ts) &
!inherits(ts, "POSIXct") &
!inherits(ts, "POSIXlt")) {
stop("We expected a unix timestamp as an integer or a POSIXct or POSIXlt value")
}