Skip to content

Instantly share code, notes, and snippets.

View rmflight's full-sized avatar

Robert M Flight rmflight

View GitHub Profile
@yihui
yihui / knitr-alert.Rnw
Last active April 30, 2018 22:12
A collection of demos for knitr hooks
\documentclass{beamer}
\usepackage{url}
\begin{document}
<<setup, include=FALSE, tidy=FALSE, highlight=FALSE>>=
# do not use the highlight package; will do it manually
opts_chunk$set(highlight = FALSE, tidy = FALSE)
tokens = c('dlmMLE', 'dlmModReg') # a list of words to be highlighted by structure{}
knit_hooks$set(
chunk = function(x, options) {
@rmflight
rmflight / setupknitr.md
Created June 15, 2012 18:44
knitr setup for Rmd files

This code block goes at the top of every Rmd file that I create for eventual conversion by knitr

# sets output for inline results nicely
knit_hooks$set(inline = identity) 

# kills knitr if there is an error, therefore we don't waste time generating error messages
knit_hooks$set(error = function(x, options) stop(x)) 

# these are extremely useful options for working in R
library(memoise)
library(stringr)
git_prompt <- function() {
git <- find_git()
if (is.null(git)) stop("Git not installed", call. = FALSE)
if (!in_git_repo(git)) stop("Not in git repo", call. = FALSE)
update <- function(...) update_prompt(git)
@dsparks
dsparks / letters_as_shapes.R
Created October 25, 2012 22:09
Plotting letters as shapes
doInstall <- TRUE # Change to FALSE if you don't want packages installed.
toInstall <- c("foreign", "ggplot2", "devtools")
if(doInstall){install.packages(toInstall, repos = "http://cran.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
source_gist("https://gist.github.com/818983")
source_gist("https://gist.github.com/818986")
source_gist("https://gist.github.com/818998")
# Get NOMINATE data from voteview.org
@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

@sgsfak
sgsfak / gist:98a5ca34bffe41958f88
Last active September 18, 2017 07:59
Adding a `git hub` alias
git config --global alias.hub '!open $(git config --get remote.origin.url | sed -e "s|git@github\.com:|https://github.com/|" -e "s|git@bitbucket\.org:|https://bitbucket.org/|" -e "s|\.git$||")'

been working on the fulltext package lately - and starting thinking

hmmmmmm, it's probably not that easy to extract text from articles for those not familiar with XML, XPATH, etc.

So this happened recently:

Installation, loading

@konrad
konrad / get_bosc_tweets.py
Last active May 6, 2016 19:50
An example how to get all tweets containing a hashtag (here #BOSC2015) and storing each tweets as JSON string.
from TwitterSearch import *
import json
try:
tso = TwitterSearchOrder()
tso.set_keywords(['#BOSC2015'])
# Please replace with your credentials
ts = TwitterSearch(
consumer_key='REPLACE_ME',
consumer_secret='REPLACE_ME',
@hussius
hussius / kallisto_setup.sh
Last active December 11, 2020 15:45
Kallisto setup
# Download Kallisto and sratools (the latter to be able to download from SRA)
wget https://github.com/pachterlab/kallisto/releases/download/v0.42.3/kallisto_mac-v0.42.3.tar.gz
tar zvxf kallisto_mac-v0.42.3.tar.gz
wget http://ftp-trace.ncbi.nlm.nih.gov/sra/sdk/2.5.2/sratoolkit.2.5.2-mac64.tar.gz
tar zxvf sratoolkit.2.5.2-mac64.tar.gz
# Download and merge human cDNA and ncDNA files from Ensembl for the index.
wget ftp://ftp.ensembl.org/pub/current_fasta/homo_sapiens/cdna/Homo_sapiens.GRCh38.cdna.all.fa.gz
wget ftp://ftp.ensembl.org/pub/current_fasta/homo_sapiens/ncrna/Homo_sapiens.GRCh38.ncrna.fa.gz
cat Homo_sapiens.GRCh38.cdna.all.fa.gz Homo_sapiens.GRCh38.ncrna.fa.gz > Homo_sapiens.GRCh38.rna.fa.gz
@gaborcsardi
gaborcsardi / cran-over-time.R
Last active July 18, 2020 19:21
Size of the CRAN R package repository over time
library(jsonlite)
## Download
pkgs <- fromJSON("http://crandb.r-pkg.org/-/events")
## Filter
na_pkgs <- unique(pkgs$name[ is.na(pkgs$date) ])
events <- pkgs[ ! pkgs$name %in% na_pkgs, c("date", "name", "event")]