首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通货膨胀率时间序列

通货膨胀率时间序列
EN

Stack Overflow用户
提问于 2020-01-17 03:12:59
回答 1查看 104关注 0票数 0

你好,我有一个20年的CPI数据集,我计算了通货膨胀率:

代码语言:javascript
复制
"/" <- function(x,y) ifelse(y==0,0,base:::"/"(x,y))

n <- length(CPI.germany$CPI)

infl <- CPI.germany$CPI[13:n]/CPI.germany$CPI[1:(n-12)]

# adjust the date column
date <- CPI.germany1$Date
datenew<- date[13:252]

#control
length(datenew)
length(infl)

 infl    datenew
1    1.08182862 1991-01-15
2    1.08195654 1991-02-15
3    1.08191389 1991-03-15
4    1.22093054 1991-04-15
5    1.28206524 1991-05-15
6    1.56516705 1991-06-15
7    2.01404189 1991-07-15
8    1.58665134 1991-08-15

我如何知道如何创建像我附加的那样的时间序列图。那么哪个包是最简单的呢?ggplot2?

EN

回答 1

Stack Overflow用户

发布于 2020-01-17 04:28:34

假设在结尾处的注释中重复显示了DF,将其转换为zoo系列z,然后使用所示的方法之一。

代码语言:javascript
复制
library(zoo)
z <- read.zoo(DF, index = "datenew")

# classic graphics
plot(z)

# ggplot2
library(ggplot2)
autoplot(z)

# lattice
library(lattice)
xyplot(z)

备注

代码语言:javascript
复制
Lines <- " infl    datenew
1    1.08182862 1991-01-15
2    1.08195654 1991-02-15
3    1.08191389 1991-03-15
4    1.22093054 1991-04-15
5    1.28206524 1991-05-15
6    1.56516705 1991-06-15
7    2.01404189 1991-07-15
8    1.58665134 1991-08-15"
DF <- read.table(text = Lines)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59776355

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档