[英]Time series with 4 lectures in each year in R
Hi coommunity嗨社区
Im want make a time series
.我想做一个
time series
。 But I dont understan how to put adecuate frecuency()
in my data.但我不明白如何在我的数据中放入适当的频率
frecuency()
。 Because I have 4 lectures in each year.因为我每年有 4 节课。
Im run this code with different frecuency()
.我用不同的
frecuency()
运行这段代码。
col <- ts(data, start=(2005), end=(2017), frecuency=3)
col2 <- ts(data, start=(2005), end=(2017), frecuency=4)
Appear this error in both frecuency:两种频率都出现这个错误:
Error in ts(data, start = (2005), end = (2017), frecuency = 3): unused argument (frecuency = 3)
ts(数据,开始 =(2005),结束 =(2017),频率 = 3)中的错误:未使用的参数(频率 = 3)
Short example of data:数据的简短示例:
data<-dput(data2[1:50,c(1,5)])
structure(list(`Año(aaaa) Trimestre` = c("2005-I", "2005-II",
"2005-III", "2005-IV", "2006-I", "2006-II", "2006-III", "2006-IV",
"2007-I", "2007-II", "2007-III", "2007-IV", "2008-I", "2008-II",
"2008-III", "2008-IV", "2009-I", "2009-II", "2009-III", "2009-IV",
"2010-I", "2010-II", "2010-III", "2010-IV", "2011-I", "2011-II",
"2011-III", "2011-IV", "2012-I", "2012-II", "2012-III", "2012-IV",
"2013-I", "2013-II", "2013-III", "2013-IV", "2014-I", "2014-II",
"2014-III", "2014-IV", "2015-I", "2015-II", "2015-III", "2015-IV",
"2016-I", "2016-II", "2016-III", "2016-IV", "2017-I", "2017-II"
), Intereses = c(3487.7340796913, 2636.1720431842, 4098.7810605988,
1127.7775577085, 3898.7200068568, 3173.4231650307, 5200.9872227416,
2568.5529693648, 4563.7053724986, 3689.8479045882, 5328.9957833292,
3027.943784559, 3216.4330560052, 3590.2597494772, 4921.7015570933,
3509.2270647808, 3267.2335649236, 3752.591130593, 5309.6809854114,
3640.7569827354, 2808.0944016763, 4384.7273283165, 5153.7080387692,
3293.4313083865, 2888.6304625115, 5441.9009141676, 5345.4405829456,
4035.0252381896, 3274.6679703078, 4440.9410689445, 5620.2510678808,
3971.8280391794, 3137.8612868065, 4763.6464493441, 5098.6004975375,
4370.5127517673, 2916.9675160472, 4461.8158321922, 6220.9851841919,
3750.8295027979, 3173.8139113252, 4124.7981239368, 7800.2754718405,
5112.4716690847, 4093.9792156983, 5224.9834134052, 10451.3900750738,
3725.9879281201, 4051.180479499, 7013.2845555995)), row.names = c(NA,
-50L), class = c("tbl_df", "tbl", "data.frame"))
Thanks谢谢
You can define your data2 as您可以将 data2 定义为
data2 <- structure(list(`Año(aaaa) Trimestre` = c("2005-I", "2005-II",
"2005-III", "2005-IV", "2006-I", "2006-II", "2006-III", "2006-IV",
"2007-I", "2007-II", "2007-III", "2007-IV", "2008-I", "2008-II",
"2008-III", "2008-IV", "2009-I", "2009-II", "2009-III", "2009-IV",
"2010-I", "2010-II", "2010-III", "2010-IV", "2011-I", "2011-II",
"2011-III", "2011-IV", "2012-I", "2012-II", "2012-III", "2012-IV",
"2013-I", "2013-II", "2013-III", "2013-IV", "2014-I", "2014-II",
"2014-III", "2014-IV", "2015-I", "2015-II", "2015-III", "2015-IV",
"2016-I", "2016-II", "2016-III", "2016-IV", "2017-I", "2017-II"
), Intereses = c(3487.7340796913, 2636.1720431842, 4098.7810605988,
1127.7775577085, 3898.7200068568, 3173.4231650307, 5200.9872227416,
2568.5529693648, 4563.7053724986, 3689.8479045882, 5328.9957833292,
3027.943784559, 3216.4330560052, 3590.2597494772, 4921.7015570933,
3509.2270647808, 3267.2335649236, 3752.591130593, 5309.6809854114,
3640.7569827354, 2808.0944016763, 4384.7273283165, 5153.7080387692,
3293.4313083865, 2888.6304625115, 5441.9009141676, 5345.4405829456,
4035.0252381896, 3274.6679703078, 4440.9410689445, 5620.2510678808,
3971.8280391794, 3137.8612868065, 4763.6464493441, 5098.6004975375,
4370.5127517673, 2916.9675160472, 4461.8158321922, 6220.9851841919,
3750.8295027979, 3173.8139113252, 4124.7981239368, 7800.2754718405,
5112.4716690847, 4093.9792156983, 5224.9834134052, 10451.3900750738,
3725.9879281201, 4051.180479499, 7013.2845555995)), row.names = c(NA,
-50L), class = c("tbl_df", "tbl", "data.frame"))
Then convert to timeseries (spelling "frequency" as noted in comments) as然后转换为时间序列(如注释中所述拼写“频率”)为
col <- ts(data2$`Año(aaaa) Trimestre`, start=(2005), end=(2017), frequency=3)
which gives这使
col
Time Series:
Start = c(2005, 1)
End = c(2017, 1)
Frequency = 3
[1] 2005-I 2005-II 2005-III 2005-IV 2006-I 2006-II 2006-III
[8] 2006-IV 2007-I 2007-II 2007-III 2007-IV 2008-I 2008-II
[15] 2008-III 2008-IV 2009-I 2009-II 2009-III 2009-IV 2010-I
[22] 2010-II 2010-III 2010-IV 2011-I 2011-II 2011-III 2011-IV
[29] 2012-I 2012-II 2012-III 2012-IV 2013-I 2013-II 2013-III
[36] 2013-IV 2014-I
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.