Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@noamross
noamross / base_r_plotting_tutorial_koontz_d-rug.r
Created April 24, 2015 17:34
Back to basics: High quality plots using base R graphics
### Title: Back to basics: High quality plots using base R graphics
### An interactive tutorial for the Davis R Users Group meeting on April 24, 2015
###
### Date created: 20150418
### Last updated: 20150423
###
### Author: Michael Koontz
### Email: mikoontz@gmail.com
### Twitter: @michaeljkoontz
###
@noamross
noamross / SEM example.R
Created May 20, 2015 18:16
A first look at structured equation models using the Lavaan package
# A FIRST LOOK AT LAVAAN
## By Grace Charles, presented at Davis R Users' Group on May 15, 2015
## adapted from Jim Grace's SEM workshop and Lavaan tutorials
# Set your working directory
setwd("~/Desktop/DAVIS/sem workshop")
###Load Libraries
library(lavaan)
@noamross
noamross / test.R
Created June 22, 2015 20:14
test for import::from
myfunc <- function(x) {
x + 1
}
@noamross
noamross / disease_tweeps.R
Last active August 29, 2015 14:23
I wanted to make a list of my disease ecology followers and followees on twitter, so...
library(twitteR)
library(rlist)
library(pipeR)
library(stringi)
# Authenticate with twitter
# consumer/access keys and secrets for the twitter API must be defined elsewhere
setup_twitter_oauth(consumer_key, consumer_secret, access_token, access_secret)
# Get all my followers and followees
@noamross
noamross / gist:b902d1cda9bedb1bd060
Last active August 29, 2015 14:24
Capturing all console output, including messages from C programs, etc
conn <- textConnection("printed_output", "w", local = TRUE)
sink(conn, type=c("output"))
sink(conn, type=c("message"))
install.packages("ggplot2")
sink(NULL)
printed_output
# This will append the text to the printed_output variable, so clear it beforehand.
@noamross
noamross / BlockHole-tweetdeck.css
Last active January 7, 2016 23:12 — forked from mcnees/BlockHole.css
Change "Block" to "Drop Into Black Hole" in a Twitter account's dropdown action menu.
/* Install the Stylish extension for your browser, add this code
as a new Style, and apply it to the domain 'tweetdeck.twitter.com' */
/* You can get Stylish here: */
/* Safari - http://sobolev.us/stylish/ */
/* Chrome - https://chrome.google.com/webstore/detail/stylish/fjnbnpbmkenffdnngjfgmeleoegfcffe */
/* Tweet improvements, comments, or corrections to @mcnees. */
/* ------------------------------------------------------------- */
@noamross
noamross / source_rmd.R
Last active December 13, 2023 18:52
Source an RMD file
#' Source the R code from an knitr file, optionally skipping plots
#'
#' @param file the knitr file to source
#' @param skip_plots whether to make plots. If TRUE (default) sets a null graphics device
#'
#' @return This function is called for its side effects
#' @export
source_rmd = function(file, skip_plots = TRUE) {
temp = tempfile(fileext=".R")
knitr::purl(file, output=temp)
@noamross
noamross / keystrokes.R
Created March 21, 2016 16:08 — forked from ottlngr/keystrokes.R
Visualizing keystrokes using ggplot2
##### Visualizing keystrokes using ggplot2 #####
library(ggplot2)
# a character string to visualize:
string <- 'R is an integrated suite of software facilities for data manipulation, calculation and graphical display.'
# a data.frame representing the keys of a qwerty keyboard
qwerty <- data.frame(
id = 1:47,
mpg cyl disp hp drat wt qsec vs am gear carb
Mazda RX4 21 6 160 110 3.9 2.62 16.46 0 1 4 4
Mazda RX4 Wag 21 6 160 110 3.9 2.875 17.02 0 1 4 4
Datsun 710 22.8 4 108 93 3.85 2.32 18.61 1 1 4 1
Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1
Hornet Sportabout 18.7 8 360 175 3.15 3.44 17.02 0 0 3 2
Valiant 18.1 6 225 105 2.76 3.46 20.22 1 0 3 1
Duster 360 14.3 8 360 245 3.21 3.57 15.84 0 0 3 4
Merc 240D 24.4 4 146.7 62 3.69 3.19 20 1 0 4 2
Merc 230 22.8 4 140.8 95 3.92 3.15 22.9 1 0 4 2