Yesterday I announced that I wrote a simple R package darklyplot. This is a vignette I have built to help explain ways you can use the package.
The goal of darklyplot is to create simple time series plots with a dark background. The miniminum and maximum values are highlighted, and color coded along with the y axis and x axis labels. This vignette walks through basic usage and explores some of the package options.
Today I try my hand at building an R package called darklyplot. This package is a little extension of ggplot2 to create a dark themed time series plot.
This packages lets you create simple dark-theme times series plots. It extends ggplot2 and relies on mdthemes to make color coded axis labels. The axis labels use ggthemes::geom_rangeframe to create Tufte-like axes. Through parameters, the user can alter the colors, include shading under the line, and also add a single reference line.
Over on Twitter Grant McDermott shares a neat ggplot2 trick:
A shortcut I like to use is calling multiple geoms in an lapply() call, since this automatically generates a list. Works well for investigating plotting variations, e.g.
ggplot(diamonds, aes(carat)) +
lapply(c(50,200), function(b) geom_histogram(bins=b, alpha=0.3)) https://t.co/hf0vtvDkbk pic.twitter.com/jmmqlyJEKo
— Grant McDermott (@grant_mcdermott) June 22, 2020 I applied this trick to create a gradient fill for a chart.
Looks kind of like Kool-Aid.
Coronavirus Recession
Over on LinkedIn I posted a summary of recent economic talks I have been giving: The Coronavirus Recession. Read the whole things for analysis and lots of charts, but I leave off with three key questions:
Recession was here, but is it already gone?
Housing market indicators have rebounded, but will the recovery be sustained?
After effects of shutdown and possible second wave to the pandemic remain as risks to the outlook, how big are these risks?
Yesterday I completed the elusive presentation quadfecta. I did a talk on Zoom, Teams, WebEx and Skype. These communication apps are great, but after a few hours of maintaining “resting Zoom face” (you want to look interested as the camera is always rolling), I felt a bit exhausted.
But it was totally worth it. The highlight for me was being able to join Jeffrey Shaffer, Steve Wexler, Amanda Makulec, and Andy Cotgreave for Chart Chat.
A couple years ago I posted R code for a remix of a remix of a US state unemployment rate chart.
Post Working on a workout. Some of the images were lost in a blog transition. We’ll update below.
Here’s an updated version:
And another remix focusing just on April 2020 (latest data).
R code
######################
## Load Libraries ##
######################
library(data.table)
library(quantmod)
library(tidyverse)
library(geofacet)
# Download data big file
ur.
Earlier this week, I made a boss chart:
https://t.co/6wf40jtqHI pic.twitter.com/xlv3Uzpiv0
— 📈 Len Kiefer 📊 (@lenkiefer) May 12, 2020 While listening to Chart Chat I heard Jeffrey Shaffer, Steve Wexler, Amanda Makulec, and Andy Cotgreave discuss tornado charts. I decided it might be a good idea to make one. Because I’m not sure I can trust with the awesome power inherent in these charts I won’t post R code here.
Yesterday I gave a virtual talk at Gonzaga University hosted by Ryan Herzog.
Below are the slides I used, here is a link (pdf).
This week the Freddie Mac Primary Mortgage Market Survey reported a record low for the U.S. weekly average 30-year mortgage rate.
First some charts, then below I post R code.
R code
Load libraries
library(fredr)
library(tidyverse)
library(patchwork)
library(cowplot)
library(gganimate)
library(lubridate) # updated
You’ll need a custom color scale (see below for code).
R code to wrangle data
data preparation code
source(paste0(mydir,"len_color_scales.R")) #custom color scale code copied below
fredr_set_key("YOURKEY")
df <- fredr(series_id = "MORTGAGE30US",
observation_start = as.
Earlier this week I gave a talk and used this picture to compare myself last summer to this spring.
Some key differences.
Last summer I was:
clean shaven
provoking bears
This spring I am:
sporting a quarantine beard
dealing with sassy autofill
Despite what autofill was suggesting I think there’s some reason for optimism, though no doubt recent weeks have been tough.
Last summer, when I took the photo with the bears, I was up in New York City.