Skip to content

Instantly share code, notes, and snippets.

time15 RUB_sol MFA_sol NFA_sol NFY_sol SFY_baro_air NFA_baro_air
4/30/2012 0:15 11.929 12.689 11.26 8.19 9.43 13.134
4/30/2012 0:30 11.879 12.627 11.28 8.18 9.25 12.925
4/30/2012 0:45 11.828 12.57 11.26 8.21 9.03 12.736
4/30/2012 1:00 11.779 12.511 11.23 8.22 8.82 12.605
4/30/2012 1:15 11.73 12.459 11.17 8.23 8.6 12.455
4/30/2012 1:30 11.682 12.397 11.15 8.24 8.42 12.335
4/30/2012 1:45 11.635 12.353 11.13 8.27 8.22 12.206
4/30/2012 2:00 11.589 12.296 11.08 8.28 8.06 12.083
4/30/2012 2:15 11.545 12.25 11.03 8.29 7.89 11.95
4/30/2012 0:15 11.929 12.689 11.26 8.19 9.43 13.134
4/30/2012 0:30 11.879 12.627 11.28 8.18 9.25 12.925
4/30/2012 0:45 11.828 12.57 11.26 8.21 9.03 12.736
4/30/2012 1:00 11.779 12.511 11.23 8.22 8.82 12.605
4/30/2012 1:15 11.73 12.459 11.17 8.23 8.6 12.455
4/30/2012 1:30 11.682 12.397 11.15 8.24 8.42 12.335
4/30/2012 1:45 11.635 12.353 11.13 8.27 8.22 12.206
4/30/2012 2:00 11.589 12.296 11.08 8.28 8.06 12.083
4/30/2012 2:15 11.545 12.25 11.03 8.29 7.89 11.95
@noamross
noamross / Air_Water_loggers_15min_example.csv
Created February 6, 2013 23:53
A tutorial on using xts and ggplot for time series data
4/30/2012 0:15 11.929 12.689 11.26 8.19 9.43 13.134
4/30/2012 0:30 11.879 12.627 11.28 8.18 9.25 12.925
4/30/2012 0:45 11.828 12.57 11.26 8.21 9.03 12.736
4/30/2012 1:00 11.779 12.511 11.23 8.22 8.82 12.605
4/30/2012 1:15 11.73 12.459 11.17 8.23 8.6 12.455
4/30/2012 1:30 11.682 12.397 11.15 8.24 8.42 12.335
4/30/2012 1:45 11.635 12.353 11.13 8.27 8.22 12.206
4/30/2012 2:00 11.589 12.296 11.08 8.28 8.06 12.083
4/30/2012 2:15 11.545 12.25 11.03 8.29 7.89 11.95
@noamross
noamross / gist:5447008
Created April 23, 2013 20:14
proftable(), and improved summaryRprof() for code profiling in R
proftable <- function(file, lines=20) {
require(plyr)
sample.interval <- as.numeric(strsplit(readLines(file, 1), "=")[[1L]][2L])/1e+06
profdata <- as.matrix(read.table(file, header=FALSE, sep=" ", colClasses="character", skip=1, fill=TRUE, na.strings=""))
total.time <- nrow(profdata)*sample.interval
stacktable <- data.frame(table(aaply(profdata, 1, function(x) paste(rev(na.omit(x)), collapse=" > "))))
names(stacktable) <- c("Stack","PctTime")
stacktable$PctTime <- 100*stacktable$PctTime/nrow(profdata)
stacktable <- stacktable[order(stacktable$PctTime, decreasing=TRUE), c("PctTime", "Stack")]
rownames(stacktable) <- NULL
@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 / findmins.R
Last active January 21, 2016 00:11
Ways to find the N minimum value in a vector
#Looking for a fast way to find the N minimum values in a vector of values. For use in finding nearest neighbors when one already has a (large) distance matrix.
x <- runif(5000)
n <- 3
system.time({ # What I'm using now
for(i in 1:10000) {
a <- sort(x)[1:n]
b <- match(a, x)
}
@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,
@noamross
noamross / density.R
Last active July 27, 2016 04:55
Overlapping Density Plots
library(dplyr)
library(tidyr)
library(ggplot2)
library(gridExtra)
df = data_frame(a = rnorm(100, mean=1), b=rnorm(100, mean=2), c=rnorm(100, mean=0)) %>%
gather("var", "value", a,b,c)
ggplot(df, aes(x=value)) +
geom_density(fill="black", col="white", lwd=1) +
@noamross
noamross / formatting plots for pubs.R
Created November 21, 2013 05:18
Code from presentation to Davis R Users's group by Rosemary Hartman, November 20, 2013, on formatting plots for publication.
#'% How to format plots for publication using `ggplot2` (with some help from Inkscape)
#'% Rosemary Hartman
#'% 13-11-20 19:51:47
#'
#' ***The following is the code from a presentation made by Rosemary Hartman to
#' the [Davis R Users' Group](http://www.noamross.net/davis-r-users-group.html).
#' I've run the code through the `spin` function in `knitr` to produce this post.
#' Download the script to walk through [here](https://gist.github.com/noamross/7576436)***
#'
#' First, make your plot. I am going to use the data already in R
@noamross
noamross / quartzbug.R
Created December 10, 2016 21:59
Bug in R quartz() device
# I believe I found a bug in R's quartz() device, specifically it's
# GECap method (the C routine called by dev.capture). The following
# yields the two images in the comment below. This occurs whether working
# from the terminal or RStudio. This works fine with Cairo devices that
# support raster capture.
quartz()
plot(1,1)
aa <- dev.capture()
dev.size("px")