# ------------------------------------------------------------------------------ # BEA.R # Reads in NIPA data from the BEA table by table # Current version hard codes the desired line numbers # See: http://www.bea.gov/national/nipaweb/DownSS2.asp # Thanks to Kenneth Pond at the BEA for his help # Written by: Jeffrey Cheng and Dave Backus, November 2012 # With input from Espen Henriksen # ------------------------------------------------------------------------------ # clear memory, set directory for output rm(list=ls()) # remember to change \ to / dir = "c:/Users/dbackus/Documents/Papers/BCH/data/BEA" setwd(dir) # ------------------------------------------------------------------------------ # 1. Download data data.url <- "http://www.bea.gov/national/nipaweb/SS_Data/Section3All_csv.csv" download.file(data.url, destfile="test.csv") table31 <- read.csv(file=data.url, sep=",", skip=7, nrows=40) table32 <- read.csv(file=data.url, sep=",", skip=130, nrows=47) table33 <- read.csv(file=data.url, sep=",", skip=277, nrows=40) # Espen's version # Download Table 1.1.5 Gross Domestic Product from BEA and assign it to a data frame called "beatbl115" # Comments: Ann = annual t115q <- read.csv("http://www.bea.gov/national/nipaweb/csv/NIPATable.csv?FirstYear=1947&TableName=5&LastYear=2012&ViewSeries=NO&freq=Qtr&3Place=N&Request3Place=N",skip=0,sep=",") t115a <- read.csv("http://www.bea.gov/national/nipaweb/csv/NIPATable.csv?FirstYear=1947&TableName=5&LastYear=2012&ViewSeries=NO&freq=Ann&3Place=N&Request3Place=N",skip=4,sep=",") t115b <- read.csv("http://www.bea.gov/national/nipaweb/csv/NIPATable.csv?FirstYear=1947&TableName=25&LastYear=2012&ViewSeries=NO&freq=Ann&3Place=N&Request3Place=N",sep=",")