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
stpdf = as(stfdf, "STSDF")
stpdf[1:2,]
stpdf[,1:2]
stpdf[,,2]
stpdf[,,"values"]
stpdf[1,]
stpdf[,2]
# examples for [[, [[<-, $ and $<-
stpdf[[1]]
stpdf[["values"]]
stpdf[["newVal"]] <- rnorm(12)
stpdf$ID
stpdf$ID = paste("OldIDs", 1:12, sep="")
stpdf$NewID = paste("NewIDs", 12:1, sep="")
stpdf
Run the code above in your browser using DataLab