- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
library(quantmod)
getSymbols("GDPC1",src = "FRED")
我正在尝试提取 FRED 中的数字经济/金融数据以及元数据。我正在尝试绘制 CPI 图表并将元数据作为标签/脚注。有没有办法使用 quantmod 包提取这些数据?
Title: Real Gross Domestic Product
Series ID: GDPC1
Source: U.S. Department of Commerce: Bureau of Economic Analysis
Release: Gross Domestic Product
Seasonal Adjustment: Seasonally Adjusted Annual Rate
Frequency: Quarterly
Units: Billions of Chained 2009 Dollars
Date Range: 1947-01-01 to 2014-01-01
Last Updated: 2014-06-25 7:51 AM CDT
Notes: BEA Account Code: A191RX1
Real gross domestic product is the inflation adjusted value of the
goods and services produced by labor and property located in the
United States.
For more information see the Guide to the National Income and Product
Accounts of the United States (NIPA) -
(http://www.bea.gov/national/pdf/nipaguid.pdf)
最佳答案
您可以使用 getSymbools.FRED
正文中的相同代码,但将“.csv”更改为“.xls”,然后从 .xls 中读取您感兴趣的元数据文件。
library(gdata)
Symbol <- "GDPC1"
FRED.URL <- "http://research.stlouisfed.org/fred2/series"
tmp <- tempfile()
download.file(paste0(FRED.URL, "/", Symbol, "/downloaddata/", Symbol, ".xls"),
destfile=tmp)
read.xls(tmp, nrows=17, header=FALSE)
# V1 V2
# 1 Title: Real Gross Domestic Product
# 2 Series ID: GDPC1
# 3 Source: U.S. Department of Commerce: Bureau of Economic Analysis
# 4 Release: Gross Domestic Product
# 5 Seasonal Adjustment: Seasonally Adjusted Annual Rate
# 6 Frequency: Quarterly
# 7 Units: Billions of Chained 2009 Dollars
# 8 Date Range: 1947-01-01 to 2014-01-01
# 9 Last Updated: 2014-06-25 7:51 AM CDT
# 10 Notes: BEA Account Code: A191RX1
# 11 Real gross domestic product is the inflation adjusted value of the
# 12 goods and services produced by labor and property located in the
# 13 United States.
# 14
# 15 For more information see the Guide to the National Income and Product
# 16 Accounts of the United States (NIPA) -
# 17 (http://www.bea.gov/national/pdf/nipaguid.pdf)
<小时/>
您可以使用 grep
来搜索具有数据标题的行,而不是硬编码 nrows=17
,并且子集仅包含在此之前的行。
dat <- read.xls(tmp, header=FALSE, stringsAsFactors=FALSE)
dat[seq_len(grep("DATE", dat[, 1])-1),]
unlink(tmp) # remove the temp file when you're done with it.
关于r - R 中的 Quantmod FRED 元数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24985267/
我想使用 R 的 quantmod 包来测试一些交易股票的技术指标。 我的目标是在股票代码上自动运行指标,结果告诉我如果我严格遵循指标(例如 MACD),我的表现会怎样。 www.quantmod.c
我明天要交我的论文,我收到了一个非常奇怪的 quantmod 错误消息,这是我在过去几周使用这个包时从未遇到过的。我无法导入特定于道琼斯指数 (^DJI) 的数据。我收到以下错误消息: getSymb
首先,我使用 TTR 包中的 stoch 函数来计算慢随机,然后使用 addTA 函数将其添加到 chartSeries 函数的绘图中,但是,绘图中的这两行是黑色的,我想更改它们变成不同的颜色。 In
利用 quantmod 包中的 ChartSeries 函数,我想修改 RSI 振荡器。给定一个包含 OHLC 价格数据的 xts 对象,这是我正在使用的调用: chartSeries(plot_re
首先,我使用 TTR 包中的 stoch 函数来计算慢随机,然后使用 addTA 函数将其添加到 chartSeries 函数的绘图中,但是,绘图中的这两行是黑色的,我想更改它们变成不同的颜色。 In
我正在使用 quantmod 包。我有一个这样的代码向量: c("AAPL","GOOG","IBM","GS","AMZN","GE") 我想创建一个函数来计算股票的 EBIT 利润率(= 营业收入
我正在尝试导入所有在 NYSE 上市的公司的财务报表,这些公司的市值大于样本的第一个四分位数。这是我的代码: require(TTR) require(quantmod) data.init="201
getSymbols("2222.SR") [1] "2222.SR" OPEN1<-Op(2222.SR) Error: unexpected symbol in "OPEN1<-Op(2222.S
我找不到任何关于如何在 quantmod 图表中突出显示单个蜡烛的信息。这是一个示例代码: library(quantmod) getSymbols("AAPL", src="yahoo") char
我想在 quantmod::chart_Series() 下方绘制热图。如何将以下热图添加到 chart_Series(或 xts::plot.xts): library(quantmod) # Ge
这个问题在这里已经有了答案: Access odd-named object returned by getSymbols (4 个回答) 6年前关闭。 执行以下命令时,代码 HM-B.ST 中的连字
我正在使用 quantmod 包来获取股票数据。编码 Data = getSymbols('LON:ADN',src="google",auto.assign=FALSE, from = '2011-
如何使用 Yahoo 的 getSymbols 显示可用的所有报价/数据系列的列表? 最佳答案 我不知道有什么办法。 TTR 包有一个函数 ( stockSymbols ) 可以从 NYSE、AMEX
我有来自 SPY 的数据我想添加 200 个简单的移动平均线,问题是我只想绘制一个特定的时间范围,但我希望移动平均线考虑了所有数据,以便我可以看到它。当您绘制数据并查看所有数据的移动平均线时,就像交易
我是 quantmod 的新手,所以我想这很简单,尽管我找不到答案。 我正在尝试访问指标值,以便将其存储到变量中并能够对其进行操作。 现在我了解如何绘制指标图表,但不了解如何访问形成图表的值。 在此先
过去几个月我一直在使用该功能,但最近几天它停止工作: library(quantmod) getFX("USD/JPY") Error in open.connection(con, "rb") :
library(quantmod) last_price price_list str(price_list) List of 2 $ AAPL: num 142 $ TSLA: num 179
我读过很多 R 文档,但我找不到任何我认为可以作为答案的内容。我的额头因撞到 table 而疼痛。 ;) 这是特定于library(quantmod)的,因为这就是我想要学习的内容,但我认为这也是一个
我想使用 quantmod::chart_Series() 绘制 SPX 图表,并在下面绘制 GDP 变化和 GDP 变化的 12 个月 SMA。无论我如何尝试(我使用什么组合),要么会发生错误,要么
我是 R 新手,在创建技术指标时遇到一些问题。更具体地说,我想创建一个指标 Fibonacci,它将添加到 chartSeries 中并由 5 条水平线组成。我正在使用的数据是股票的收盘价。因此,我想
我是一名优秀的程序员,十分优秀!