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
library(tidyverse) | |
library(jsonlite) | |
#> | |
#> Attaching package: 'jsonlite' | |
#> The following object is masked from 'package:purrr': | |
#> | |
#> flatten | |
# Ref: https://stackoverflow.com/questions/7944809/assigning-null-to-a-list-element-in-r |
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
# Ref: https://jennybc.github.io/purrr-tutorial/ls02_map-extraction-advanced.html#list_inside_a_data_frame | |
# Ref: https://github.com/tidyverse/tidyr/issues/22 | |
suppressPackageStartupMessages(library(dplyr)) | |
suppressPackageStartupMessages(library(purrr)) | |
# Make iris dataset into list of data frames split by `Species`. | |
my_list <- split(iris, iris$Species) | |
str(my_list) | |
#> List of 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
--- | |
title: "R-user-group_tidyr-talk" | |
author: "Matt Pettis" | |
date: "November 22, 2017" | |
always_allow_html: yes | |
output: | |
html_document: | |
toc: true | |
--- |
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. |
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 |
- 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