R ts()函数设定时间序列

对于已有的Excel中的数据,如何整理成时间序列格式呢?

> setwd("C:\\Users\\Admin-pc\\Desktop")
> time<-read.csv("data1.csv")
> time$b
> a<-ts(time$b, frequency = 1, start = c(1900,1),end = c(1986)) #把数据框的数据变成时间序列, 从1990年开始,到1986年截至
> str(a)

Time-Series [1:87] from 1900 to 1986: 31.7 29.8 31.7 33.1 31.3 ...

#使用Kendall软件包分析

> library(Kendall)

> MannKendall(a)   #P值小于0.01
tau = 0.265, 2-sided pvalue =0.00029208

> plot(a)


> lines(lowess(time(a),a),lwd=3, col=2)  #添加趋势线

 

posted on 2016-03-10 17:35  Bella_bing  阅读(5253)  评论(0编辑  收藏  举报

导航