unstack {spacetime} | R Documentation |
write STFDF to table forms
Description
create table forms of STFDF objects
Usage
## S3 method for class 'STFDF'
unstack(x, form, which = 1, ...)
## S3 method for class 'STFDF'
as.data.frame(x, row.names, ...)
Arguments
x |
object of class |
form |
formula; can be omitted |
which |
column name or number to have unstacked |
row.names |
row.names for the data.frame returned |
... |
arguments passed on to the functions unstack or as.data.frame |
Value
unstack
returns the data in wide format, with each
row representing a spatial entity and each column a time; see
unstack for details and default behaviour.
as.data.frame
returns the data.frame in long format,
where the coordinates of the spatial locations (or line starting
coordinates, or polygon center points) and time stamps are recycled
accordingly.
Examples
sp = cbind(x = c(0,0,1), y = c(0,1,1))
row.names(sp) = paste("point", 1:nrow(sp), sep="")
library(sp)
sp = SpatialPoints(sp)
library(xts)
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)
as.data.frame(stfdf, row.names = IDs)
unstack(stfdf)
t(unstack(stfdf))
unstack(stfdf, which = 2)
[Package spacetime version 1.3-1 Index]