In [11]:
# Load the packages you intend to work with every time you start a new session
library(tseries)
library(TSA)
library(forecast)
In [4]:
ndvi <- read.csv("http://www.escet.urjc.es/biodiversos/R/ndvi.csv", header=T, sep="\t")
In [5]:
head(ndvi)
In [6]:
str(ndvi)
In [7]:
class(ndvi)
In [27]:
head(ndvi[,-1]) # all columns except for the first
In [41]:
table(ndvi$year) # 3 missing vals at beginning and end
In [42]:
# 23 observations per year (except for the first and last year)
ndvi.ts <- ts(ndvi[,3:7], start=c(2000, 4), frequency=23)
In [36]:
dim(ndvi)
In [43]:
dim(ndvi.ts)
In [47]:
class(ndvi.ts) # it's a multivariate time series (mts)
In [50]:
plot(ndvi.ts)
In [53]:
# all time series in one plot w/ different colors
plot(ndvi.ts, plot.type = "single", col=1:5)
# add a legend w/ solid line type
legend("bottomleft", lty=rep(1,5), col=1:5, legend=paste("X", 1:5, sep=""))
In [44]:
# strptime(ndvi$year, format="%Y")