Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

unstack

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 STFDF

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)

spacetime

Classes and Methods for Spatio-Temporal Data

v1.2-4
GPL (>= 2)
Authors
Edzer Pebesma [aut, cre] (<https://orcid.org/0000-0001-8049-7069>), Benedikt Graeler [ctb], Tom Gottfried [ctb], Robert J. Hijmans [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.