Learn R Programming

spacetime (version 0.5-7)

EOF: Compute spatial or temporal empirical orthogonal function (EOF)

Description

Compute spatial or temporal empirical orthogonal function (EOF)

Usage

EOF(x, how = c("spatial", "temporal"), returnPredictions = TRUE, ...)

Arguments

x
object of class STFDF
how
character; choose "spatial" or "temporal" mode
returnPredictions
logical; if TRUE, the functions are returned (i.e., predicted principle components, or PC scores); if FALSE, the object returned by prcomp is returned, which can be printed, or from which a summary can be computed; see e
...
arguments passed on to function prcomp; note that scale.=TRUE needs to be specified to obtain EOFs based on correlation (default: covariance)

Value

  • In spatial mode, the appropriate Spatial* object. In temporal mode, an object of class xts.

Examples

Run this code
if (require(gstat)) {
data(wind)
wind.loc$y = as.numeric(char2dms(as.character(wind.loc[["Latitude"]])))
wind.loc$x = as.numeric(char2dms(as.character(wind.loc[["Longitude"]])))
coordinates(wind.loc) = ~x+y
proj4string(wind.loc) = "+proj=longlat +datum=WGS84"

# match station order to names in wide table:
stations = 4:15
wind.loc = wind.loc[match(names(wind[stations]), wind.loc$Code),]
row.names(wind.loc) = wind.loc$Station
wind$time = ISOdate(wind$year+1900, wind$month, wind$day, 0)
space = list(values = names(wind)[stations])
wind.st = stConstruct(wind[stations], space, wind$time, SpatialObj = wind.loc)
wind.eof.1 = EOF(wind.st)
wind.eof.2 = EOF(wind.st, "temporal")
wind.eof.1.PCs = EOF(wind.st, returnPredictions=FALSE)
EOF(wind.st, "temporal", returnPredictions=FALSE)
summary(EOF(wind.st, returnPredictions=FALSE))
summary(EOF(wind.st, "temporal", returnPredictions=FALSE))
plot(EOF(wind.st, "temporal", returnPredictions=FALSE))
}

Run the code above in your browser using DataLab