This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Uncomment these lines to get started | |
# install(devtools) | |
# require(devtools) | |
# install_github('cosm', 'holstius') | |
require(cosm) | |
key <- 'YoQHIdrFCPkYfYHfzEfWKM6RrjKSAKxCOHRRMWNiSmtsRT0g' # read-only, for meetup | |
feed <- 23706 # Chicago, IL (AirNow) | |
feed_detail(feed, key) | |
z <- feed_history(feed, key, duration='12hours') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SoftwareSerial.h> | |
SoftwareSerial mySerial(2, 3); // RX, TX | |
void setup() | |
{ | |
Serial.begin(9600); | |
while (!Serial) { | |
; // wait for serial port to connect. Needed for Leonardo only | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' fast_POSIXct | |
#' | |
#' Quickly converts local timestamps to a POSIXct vector | |
#' | |
#' @param x timestamps (YYYY-mm-dd HH:MM:SS) | |
#' @param tz local timezone | |
#' @return POSIXct vector | |
#' @export | |
fast_POSIXct <- function(x, tz) { | |
require(fasttime) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' fast_POSIXct | |
#' | |
#' Quickly convert local timestamps to a POSIXct vector | |
#' | |
#' @param x timestamps (YYYY-mm-dd HH:MM:SS) | |
#' @param tz local timezone | |
#' @return POSIXct vector | |
#' @export | |
fast_POSIXct <- function(x, tz) { | |
stopifnot(is.character(x)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(ggplot2) | |
require(scales) | |
seq_range <- function(x, by) seq(min(x), max(x), by=by) | |
time_breaks <- function(width) { | |
function(limits) seq_range(limits, by=width) | |
} | |
scale_x_hours <- function( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' aggregate.data.table | |
#' | |
#' Use to quickly aggregate rows from a data.frame | |
#' | |
#' @param x data.table | |
#' @param by list of columns to use for grouping | |
#' @param FUN summary function | |
#' @param \dots further arguments to summary function | |
#' @param is.value determines which of the remaining columns should be aggregated (numeric, POSIXct, character, etc.) | |
#' @author David Holstius \email{david.holstius@berkeley.edu} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' format_signif | |
#' | |
#' Format numbers with a given number of significant digits | |
#' | |
#' @param x numeric vector | |
#' @param digits number of significant digits | |
#' @return character vector | |
#' @examples | |
#' x <- c(0.800, 1704.1, 43.5e6, 10, NaN, NA, Inf, 0.00) | |
#' format_signif(x, digits=3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
read.kml <- function(file, layers) { | |
require(sp) | |
require(rgdal) | |
read.layer <- function (layer_name) { | |
spobj <- rgdal::readOGR(dsn=file, layer=layer_name) | |
coords <- coordinates(spobj) | |
colnames(coords) <- c('x', 'y', 'z')[1:ncol(coords)] | |
df <- data.frame(coords, spobj@data) | |
transform(df, layer=layer_name) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?> | |
<!-- Put site-specific property overrides in this file. --> | |
<configuration> | |
<property> | |
<name>fs.default.name</name> | |
<value>hdfs://localhost:9000</value> | |
</property> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
#/** | |
# * Copyright 2007 The Apache Software Foundation | |
# * | |
# * Licensed to the Apache Software Foundation (ASF) under one | |
# * or more contributor license agreements. See the NOTICE file | |
# * distributed with this work for additional information | |
# * regarding copyright ownership. The ASF licenses this file | |
# * to you under the Apache License, Version 2.0 (the | |
# * "License"); you may not use this file except in compliance |