Introduction

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

Average weekly hours

The tidyquant package makes getting data from FRED easy. The following code grabs data on average weekly hours and plots the series.

hrs <- tq_get("AWHAETP", get = "economic.data")
ggplot(data = hrs) +
  geom_line(mapping = aes(x = date, y = price), size = 1.3) +
  xlab("") + ylab("Hours") + ggtitle("Average weekly hours of all employees")

Here’s the description of the data provided by FRED: “Average weekly hours relate to the average hours per worker for which pay was received and is different from standard or scheduled hours. Factors such as unpaid absenteeism, labor turnover, part-time work, and stoppages cause average weekly hours to be lower than scheduled hours of work for an establishment. Group averages further reflect changes in the workweek of component industries. Average weekly hours are the total weekly hours divided by the employees paid for those hours.” The data come from the Establishment Survey.

From the problems we’ve done about choosing between working and leisure, the choice to work seems relatively stable over time.

Walmart locations

Here is example R code that plots the location of Walmart stores in 1995. The data are provided by Emek Basker. More details can be found in the following sources:

  • Basker, Emek. “Job Creation or Destruction? Labor-Market Effects of Wal-Mart Expansion.” Review of Economics and Statistics 87:1 (2005) 174-183.
  • Basker, Emek. “Selling a Cheaper Mousetrap: Wal-Mart’s Effect on Retail Prices,” Journal of Urban Economics 58:2 (2005) 203-229.
library(tidyverse)
library(zipcode)
library(maps)
## Warning: package 'maps' was built under R version 3.5.1
## 
## Attaching package: 'maps'
## The following object is masked from 'package:purrr':
## 
##     map
library(mapproj)
## Warning: package 'mapproj' was built under R version 3.5.1
library(ggthemes)

# US states
us_states <- map_data("state")
(head(us_states))
##        long      lat group order  region subregion
## 1 -87.46201 30.38968     1     1 alabama      <NA>
## 2 -87.48493 30.37249     1     2 alabama      <NA>
## 3 -87.52503 30.37249     1     3 alabama      <NA>
## 4 -87.53076 30.33239     1     4 alabama      <NA>
## 5 -87.57087 30.32665     1     5 alabama      <NA>
## 6 -87.58806 30.32665     1     6 alabama      <NA>
# Zipcode data
data("zipcode")
(head(zipcode))
##     zip       city state latitude longitude
## 1 00210 Portsmouth    NH  43.0059  -71.0132
## 2 00211 Portsmouth    NH  43.0059  -71.0132
## 3 00212 Portsmouth    NH  43.0059  -71.0132
## 4 00213 Portsmouth    NH  43.0059  -71.0132
## 5 00214 Portsmouth    NH  43.0059  -71.0132
## 6 00215 Portsmouth    NH  43.0059  -71.0132
# Location of Walmart stores
dat <- read_csv("wmlocs.csv", skip = 1, col_names = TRUE)
## Parsed with column specification:
## cols(
##   .default = col_integer(),
##   State = col_character(),
##   City = col_character(),
##   County = col_character(),
##   Zip = col_character(),
##   Number = col_character(),
##   Comments = col_character()
## )
## See spec(...) for full column specifications.
# Merge in zipcode information
dat <- dat %>% 
  left_join(zipcode, by = c("Zip" = "zip"))

# Keep data from 1995
dat <- dat %>% 
  filter(CSG95 == 1,
         State != "AK",
         State != "HI") 



p <- ggplot() +
  geom_polygon(data = us_states,
               mapping = aes(x = long, y = lat, group = group), fill = "white", color = "black")
p <- p + geom_point(data = dat,
                    mapping = aes(x = longitude, y = latitude))
p <- p + coord_map(projection = "albers", lat0 = 39, lat1 = 45)
p <- p + theme_map()
(p)
## Warning: Removed 109 rows containing missing values (geom_point).

The figure depicts Walmart stores in 1995, according to data published in Chain Store Guides.