the blog

Robert W. Walker is Associate Professor of Quantitative Methods in the Atkinson Graduate School of Management at Willamette University.
He and his family live in Oregon; he is an Arsenal fan and an avid R user. This is his blog: moved from

August 23, 2021

Parameterized RMarkdown is Amazing

Parameterized R Markdown A while back, I learned that you can parameterize markdown. You can send it something to process as argument. This is amazing. Let me show an example. First, I want to build an RMarkdown file. In RStudio, that is File > New file > R Markdown. We will need to add a bit of metadata to the top. The key component is the params: argument. I want to pass a ticker with a default option.

April 26, 2021

slider is a magical way of creating moving averages

Nike’s Stock # Load libraries library(tidyquant) library(tidyverse) library(fpp3) With those libraries, I should have what I need. Let me get Nike’s stock from 2015. # Get Nike stock data Nike.Stocks <- tq_get("NKE", from="2015-01-01") Nike.Stocks %>% as_tsibble(index=date) %>% autoplot(adjusted) + labs(y="Adjusted Closing Price", title="NKE since 2015") Now I want to create monthly data. I will the yearmonth type from lubridate. By default, tidyquant uses yearmon which is different. # Create nike returns, need tq_transmute because we are taking daily data and turning it into monthly.

March 16, 2021

tabulizer Rocks

Voter Turnout in Oregon Oregon’s voter turnout data is published by the Oregon Secretary of State’s office. You can find a direct link to the .pdf here. How hard is to recover a .pdf table? Let’s see. I am going to work with tabulizer. library(tabulizer) library(dplyr) The key function for this will be extract_tables; with knowledge of that let’s see if it just automagically works. library(kableExtra) location <- 'https://sos.

March 4, 2021

tidyTuesday on Superbowl Commercials

The tidyTuesday data for the week of March 4, 2021 represent 247 rows of Superbowl advertisements coded on a few dimensions by fivethirtyeight. The original article uses 233 and there are a few with at least some missing features in the dataset. The idea was to use binary evaluations of patriotic, funny, uses sex, and a host of other characteristics to describe the universe of Super Bowl ads. One thing that stands out is the difference between Budweiser and Bud Light.

February 22, 2021

tt: Employment and Earnings

As a continuation of the #DuBoisChallenge, this week’s tidyTuesday presents employment by industry, sex, race, and occupation. There is also some scraped data from the self-service tool that generates weekly and hourly earnings data from the CPS. Let’s see what we have. library(tidyverse) library(fpp3) library(magrittr) employed <- readr::read_csv('') earn <- readr::read_csv('') employed %<>% as_tsibble(index=year, key=c(industry,major_occupation,minor_occupation,race_gender)) Let me try to plot something. employed %>% filter(race_gender=="TOTAL") %>% autoplot(employ_n) + guides(color=FALSE) To be continued….

February 8, 2021

TT: Wealth and Income

tidyTuesday-Screenshot tidyTuesday for the week of February 8, 2021 brings data from the US Census and the Urban Institute together to think about income, wealth, and racial inequality in these and other important economic indicators. There is a lot of data that they make available to accompany the nine charts about wealth inequality that they reported here. There is considerable variation in the scope and coverage of the various datasets; I will start by loading the ten datasets.

November 30, 2020

Analyzing the Trump Campaign's Solicitations

tl;dr In September of 2018, I began to track email solicitations by the Trump Campaign. I have noticed a striking pattern of increasing fundraising activity that started just after the July 4 weekend but I wanted to verify this over the span of the data. In short, something is up. The Data I will use the wonderful gmailr package to access my gmail. You need a key and an id that the vignette gives guidance on.