- Introduction
- Examples
- [Using dplyr when discovering columns in a data
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
# Inspired: | |
# https://gist.github.com/leeper/d6d085ac86d1e006167e | |
# http://www.johnmyleswhite.com/notebook/2009/12/07/implementing-push-and-pop-in-r/ | |
push <- function(x, values) { | |
assign(as.character(substitute(x)), c(x, values), parent.frame()) | |
invisible()} | |
pop <- function(x) { | |
if(length(x) == 0) {return(NA)} |
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
#!/usr/bin/env Rscript | |
#library(plyr) | |
library(dplyr) | |
library(lubridate) | |
## Datetimes, 15min increments, that span DST breaks | |
dt_str <- c( |
- Introduction
- Setup
- Datetime formats
- Timezones
- [What is a timezone, and what
-
knitr::opts_chunk$set(echo = TRUE, fig.width=12, fig.height=9, warnings=FALSE) options(width=116)
- Introduction
- Setup
- Datetime formats
- Timezones
- [What is a timezone, and what
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
## This is just a quick exploration, answering the question: | |
## How do I reconstruct a signal by picking the highest-power frequency from a periodogram? | |
## Assumes I keep the constant (DC) term. | |
## ----------------------------------------------------------------------------- | |
## Fourier decomposition exploration | |
## ----------------------------------------------------------------------------- | |
x <- 10 * sin(2 * pi * (1:75) / 25) + 300 + rnorm(1:75, 0, 2.5) | |
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
Very procedural code, but works. If I have a set of time intervals (lubridate intervals), and I want to consolidate any chain of overlapping intervals into a single interval with left end the min of all start times and right side as max of all end times, this is the code to do that. | |
``` r | |
## Consolidating intervals | |
suppressPackageStartupMessages(library(dplyr)) | |
suppressPackageStartupMessages(library(lubridate)) | |
# In this table of intervals, rows 3,4, and 5 form a chain of intervals. They should be rolled into 1 interval. | |
# And note rows 3 and 5 do not themselves overlap, but they are chained together by having overlap with row 4. |
OlderNewer