Learn R Programming

spacetime (version 0.2-2)

STFDF-class: Class "STFDF"

Description

A class for spatio-temporal data with full space-time grid; for n spatial locations and m times, n x m observations are available

Usage

STF(sp, time)
  STFDF(sp, time, data)
  ## S3 method for class 'STFDF':
[(x, i, j, ..., drop = TRUE)
  ## S3 method for class 'STFDF,xts':
coerce(from, to, strict=TRUE)

Arguments

sp
object of class Spatial
time
object of class xts
data
data frame with appropriate number of rows
x
an object of class STFDF
i
selection of spatial entities
j
selection of temporal entities (see syntax in package xts)
...
selection of attribute(s)
drop
if TRUE and a single spatial entity is selected, an object of class xts is returned; if TRUE and a single temporal entity is selected, and object of the appropriate Spatial class is returned; if FALSE, no coerc
from
object of class STFDF
to
target class
strict
ignored

Objects from the Class

Objects of this class carry full space/time grid data

Examples

Run this code
sp = cbind(x = c(0,0,1), y = c(0,1,1))
row.names(sp) = paste("point", 1:nrow(sp), sep="")
sp = SpatialPoints(sp)
time = xts(1:4, as.POSIXct("2010-08-05")+3600*(10:13))
m = c(10,20,30) # means for each of the 3 point locations
mydata = rnorm(length(sp)*length(time),mean=rep(m, 4))
IDs = paste("ID",1:length(mydata))
mydata = data.frame(values = signif(mydata,3), ID=IDs)
stfdf = STFDF(sp, time, mydata)
stfdf
stfdf[1:2,]
stfdf[,1:2]
stfdf[,,2]
stfdf[,,"values"]
stfdf[1,]
stfdf[,2]
as(stfdf, "xts")
# examples for [[, [[<-, $ and $<- 
stfdf[[1]]
stfdf[["values"]]
stfdf[["newVal"]] <- rnorm(12)
stfdf$ID
stfdf$ID = paste("OldIDs", 1:12, sep="")
stfdf$NewID = paste("NewIDs", 12:1, sep="")
stfdf

Run the code above in your browser using DataLab