Skip to content

Instantly share code, notes, and snippets.

View dholstius's full-sized avatar

David Holstius dholstius

  • Bay Area Air Quality Management District
  • San Francisco Bay Area
  • X @dholstius
View GitHub Profile
@dholstius
dholstius / fun_join.R
Last active December 23, 2015 05:41
(Left) join with custom comparator
#' (Left) join with a custom comparator
#'
#' @param left data.frame
#' @param right data.frame
#' @param by names of columns to join by
#' @param fun custom comparator (see examples)
#'
#' @examples
#' my_df <- data.frame(cyl = c(4, 4, 6, 8), vs = c(0, 1, NA, NA), foo = c("A", "B", "C", "D"))
#' my_fun <- function (e1, e2) (e1 == e2) | is.na(e2)
@dholstius
dholstius / fast_POSIXct.r
Created November 27, 2012 20:12
Quickly convert local timestamps to a POSIXct vector
#' 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))