Trade Balance: Goods and Services, Balance of Payments Basis (BOPGSTB)

The trade balance is the amount of exports minus imports

indicator <-fredr_series_observations(series_id = "BOPGSTB",
        observation_start = as.Date("2010-01-01")) 

# plotting data
ggplot(indicator) + 
   geom_rect(aes(xmin= dmy('01-01-2020'), xmax=dmy('01-11-2021'), ymin = -Inf, ymax = Inf),
                   fill = "lightyellow", alpha = 0.02)+
  geom_line(mapping = aes(x=date,y=value),  color = "red4") +
  
  labs(title = "Trade Balance: Goods and Services", 
     subtitle = str_glue("* Balance of payments basis\n* from {min(indicator$date)} through {max(indicator$date)}"),
       x="Monthly", y="Millions of Dollars",
       caption = "Data source: FRED Federal Reserve.\nIllustration by @JoeLongSanDiego")+
    theme_economist()

Exports of Goods and Services, Balance of Payments Basis (BOPTEXP)

indicator <-fredr_series_observations(series_id = "BOPTEXP",
        observation_start = as.Date("2010-01-01")) 

# plotting data
ggplot(indicator) + 
   geom_rect(aes(xmin= dmy('01-01-2020'), xmax=maxdate, ymin = -Inf, ymax = Inf),
                   fill = "lightyellow", alpha = 0.02)+
  geom_line(mapping = aes(x=date,y=value),  color = "red4") +
  
  labs(title = "Exports of Goods and Services", 
       subtitle = str_glue("from {min(indicator$date)} through {max(indicator$date)}\n Seasonally Adjusted"),
       x="", y="Millions of dolars",
       caption = "Data source: FRED Federal Reserve.\nIllustration by @JoeLongSanDiego")+
    theme_economist()

Exports of Goods, Balance of Payments Basis (BOPGEXP)

indicator <-fredr_series_observations(series_id = "BOPGEXP",
        observation_start = as.Date("2010-01-01")) 

# plotting data
ggplot(indicator) + 
   geom_rect(aes(xmin= dmy('01-01-2020'), xmax=maxdate, ymin = -Inf, ymax = Inf),
                   fill = "lightyellow", alpha = 0.02)+
  geom_line(mapping = aes(x=date,y=value),  color = "red4") +
  
  labs(title = "Trade Balance: Export of Goods (ONLY)", 
       subtitle = str_glue("from {min(indicator$date)} through {max(indicator$date)}\nSeasonally Adjusted"),
       x="Monthly", y="Millions of dollars",
       caption = "Data source: FRED Federal Reserve.\nIllustration by @JoeLongSanDiego")+
    theme_economist()

Exports of Services, Balance of Payments Basis (BOPSEXP)

indicator <-fredr_series_observations(series_id = "BOPSEXP",
        observation_start = as.Date("2010-01-01")) 

# plotting data
ggplot(indicator) + 
   geom_rect(aes(xmin= dmy('01-01-2020'), xmax=maxdate, ymin = -Inf, ymax = Inf),
                   fill = "lightyellow", alpha = 0.02)+
  geom_line(mapping = aes(x=date,y=value),  color = "red4") +
  
  labs(title = "Exports of Services (ONLY)", 
       subtitle = str_glue("from {min(indicator$date)} through {max(indicator$date)}\nSeasonally Adjusted"),
       x="Monthly", y="Millions of dollars",
       caption = "Data source: FRED Federal Reserve.\nIllustration by @JoeLongSanDiego")+
    theme_economist()

Imports of Goods and Services: Balance of Payments Basis (BOPTIMP)

indicator <-fredr_series_observations(series_id = "BOPTIMP",
        observation_start = as.Date("2010-01-01")) 

# plotting data
ggplot(indicator) + 
   geom_rect(aes(xmin= dmy('01-01-2020'), xmax=maxdate, ymin = -Inf, ymax = Inf),
                   fill = "lightyellow", alpha = 0.02)+
  geom_line(mapping = aes(x=date,y=value),  color = "red4") +
  
  labs(title = "Imports of Goods and Services (BOTH)", 
       subtitle = str_glue("from {min(indicator$date)} through {max(indicator$date)}\nSeasonally Adjusted"),
       x="Monthly", y="Millions of dollars",
       caption = "Data source: FRED Federal Reserve.\nIllustration by @JoeLongSanDiego")+
    theme_economist()

Imports of Goods: Balance of Payments Basis (BOPGIMP)

indicator <-fredr_series_observations(series_id = "BOPGIMP",
        observation_start = as.Date("2010-01-01")) 

# plotting data
ggplot(indicator) + 
   geom_rect(aes(xmin= dmy('01-01-2020'), xmax=maxdate, ymin = -Inf, ymax = Inf),
                   fill = "lightyellow", alpha = 0.02)+
  geom_line(mapping = aes(x=date,y=value),  color = "red4") +
  
  labs(title = "Imports of Goods  (ONLY)", 
       subtitle = str_glue("from {min(indicator$date)} through {max(indicator$date)}\nSeasonally Adjusted"),
       x="Monthly", y="Millions of dollars",
       caption = "Data source: FRED Federal Reserve.\nIllustration by @JoeLongSanDiego")+
    theme_economist()

Imports of Services, Balance of Payments Basis (BOPSIMP)

indicator <-fredr_series_observations(series_id = "BOPSIMP",
        observation_start = as.Date("2010-01-01")) 

# plotting data
ggplot(indicator) + 
   geom_rect(aes(xmin= dmy('01-01-2020'), xmax=maxdate, ymin = -Inf, ymax = Inf),
                   fill = "lightyellow", alpha = 0.02)+
  geom_line(mapping = aes(x=date,y=value),  color = "red4") +
  
  labs(title = "Imports of Service  (ONLY)", 
       subtitle = str_glue("from {min(indicator$date)} through {max(indicator$date)}\nSeasonally Adjusted"),
       x="Monthly", y="Millions of dollars",
       caption = "Data source: FRED Federal Reserve.\nIllustration by @JoeLongSanDiego")+
    theme_economist()

library(reshape)
## 
## Attaching package: 'reshape'
## The following object is masked from 'package:lubridate':
## 
##     stamp
## The following object is masked from 'package:dplyr':
## 
##     rename
## The following objects are masked from 'package:tidyr':
## 
##     expand, smiths
indicator <-fredr_series_observations(series_id = "APUS49C74714",
        observation_start = as.Date("2019-01-01")) 
indicator1 <-fredr_series_observations(series_id = "APUS49B74714",
        observation_start = as.Date("2019-01-01")) 


both <- data.frame(indicator$date,indicator$value,indicator1$value)
colnames(both) <- c("date","Riverside","Bay_area")
both <-  melt(both ,  id.vars = c('date'))
# plotting data
ggplot(both) + 
   geom_rect(aes(xmin= dmy('01-01-2020'), xmax=maxdate, ymin = -Inf, ymax = Inf),
                   fill = "lightyellow", alpha = 0.02)+
  geom_line(mapping = aes(x=date,y=value,  color = variable)) +
 
  labs(title = "Gasoline, Unleaded Regular ", 
     subtitle = str_glue("from {min(indicator$date)} through {max(indicator$date)}"),
       x="Monthly", y="Dollars",
       caption = "Data source: FRED Federal Reserve\nIllustration by @JoeLongSanDiego")+
    theme_economist()