你好,我有一个20年的CPI数据集,我计算了通货膨胀率:
"/" <- 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?

发布于 2020-01-17 04:28:34
假设在结尾处的注释中重复显示了DF,将其转换为zoo系列z,然后使用所示的方法之一。
library(zoo)
z <- read.zoo(DF, index = "datenew")
# classic graphics
plot(z)
# ggplot2
library(ggplot2)
autoplot(z)
# lattice
library(lattice)
xyplot(z)备注
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)https://stackoverflow.com/questions/59776355
复制相似问题