rawData: Get data from the internet/filesystem

Description Usage Arguments Examples

Description

Aquire data.

Usage

1
rawData(url = NULL, newLocalFileName = NULL)

Arguments

url

internet url or filesystem path

newLocalFileName

current area location to save

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
## Not run: 

# recent coupon auctions
# Coupon Auctions – Data from October 2009-present?
# url <- "https://home.treasury.gov/system/files/291/September%2010_2018%20IC%20Coupons.xls"
rawData(url = url, newLocalFileName = "recentCoupons.xls")
df <- as.data.frame(
      suppressWarnings(readxl::read_excel("recentCoupons.xls"
        , col_types = "guess", skip  = 4, guess_max = 1)
      ))
col_names <- c("issue_date", "security", "coupon_rate"
             , "cusip", "maturity_date", "total_issue"
             , "SOMA_issue", "institutions_issue", "individuals_issue"
             , "dealers_issue", "pensions_issue"
             , "investment_funds_issue", "foreign_issue","other_issue"
             )
colnames(df) <- col_names
df$issue_date    <- zoo::as.Date(df$issue_date)
df$maturity_date <- zoo::as.Date(df$maturity_date)
str(df, vec.len = 3)
# 'data.frame':	803 obs. of  14 variables:
#  $ issue_date            : Date, format: "2018-08-31" "2018-08-31" "2018-08-31" ...
#  $ security              : chr  "2-Year FRN" "2-Year Note" "5-Year TIPS Note" ...
#  $ rate                  : num  0.043 2.625 0.625 2.75 ...
#  $ cusip                 : chr  "912828Y53" "9128284Y3" "9128284H0" ...
#  $ maturity_date         : Date, format: "2020-07-31" "2020-08-31" "2023-04-15" ...
#  $ total_issue           : num  18.2 38.5 15 39.6 ...
#  $ soma_issue            : num  1.198 2.537 0.987 2.608 ...
#  $ institutions_issue    : num  0 0.001 0 0.07 0.07 0.00051 0 0 ...
#  $ individuals_issue     : num  0.0203 0.393 0.0351 0.056 ...
#  $ dealers_issue         : num  8.9 15.7 2.73 9.8 ...
#  $ pensions_issue        : num  0.217 0.025 0 0 ...
#  $ investment_funds_issue: num  3.72 15.37 10.52 23.49 ...
#  $ foreign_issue         : num  0.49 4.426 0.715 3.134 ...
#  $ other_issue           : num  3.65 0.08 0 0.444 ...

## End(Not run)

AndreMikulec/UShoard documentation built on May 29, 2019, 3:02 a.m.