read.transpose
and combine the initial columns.readNIPA(files, sep.footnote='/', ...)
read.transpose
.files
.read.transpose
matrix
of the common variablesUSFinanceIndustry
from Table 6.16: Income and
employment by industry in the National Income and Product Account
tables published by the Bureau of Economic Analysis of the United
States Department of Commerce. As of February 2013, this table can be
obtained from USFinanceIndustry
data combined the first 4 rows of
the 4 annual summary tables. This is available in 4 separate files, which must be downloaded and
combined using readNIPA
. The first three of these are
historical data and are rarely revised. For convenience and for
testing, they are provided in the demoFiles
subdirectory of
this Ecdat
package.
It has not been tested on other data but should work for annual data with a sufficiently similar structure.
The algorithm proceeds as follows:
1. Data <- lapply(files, read.transpose)
2. Is Data
a list of numeric matrices? If no, print an
error.
3. cbind common initial variables, averaging overlapping years, reporting percent difference
4. attributes: stats from files and overlap. Stats include the first and last year and the last revision date for each file, plus the number of years overlap with the previous file and the relative change in the common files kept between those two files.
read.table
readLines
strsplit
# Find demoFiles/*.csv
demoDir <- system.file('demoFiles', package='Ecdat')
(demoCsv <- dir(demoDir, pattern='csv$', full.names=TRUE))
nipa6.16 <- readNIPA(demoCsv)
str(nipa6.16)
Run the code above in your browser using DataLab