File: rw.Rout.save

package info (click to toggle)
r-cran-spacetime 1.2-4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,308 kB
  • sloc: sh: 13; makefile: 2
file content (57 lines) | stat: -rw-r--r-- 1,765 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

R version 3.6.2 (2019-12-12) -- "Dark and Stormy Night"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> suppressPackageStartupMessages(library(sp))
> suppressPackageStartupMessages(library(spacetime))
> 
> m = 3# nr of trajectories
> n = 100 # length of each
> l = vector("list", m)
> t0 = as.POSIXct("2013-05-05",tz="GMT")
> set.seed(1331)
> for (i in 1:m) {
+     x = cumsum(rnorm(n))
+     y = cumsum(rnorm(n))
+     sp = SpatialPoints(cbind(x,y))
+     #t = t0 + (0:(n-1) + (i-1)*n) * 60
+     t = t0 + (0:(n-1) + (i-1)*n/2) * 60
+     l[[i]] = STI(sp, t)
+ }
> stt= STT(l)
> sttdf = STTDF(stt, data.frame(attr = rnorm(n*m), id = paste("ID", rep(1:m, each=n))))
> x = as(stt, "STI")
> stplot(sttdf, col=1:m, scales=list(draw=TRUE))
> stplot(sttdf, by = "id")
> stplot(sttdf[1])
> stplot(sttdf[1])
> 
> p = Polygon(cbind(x=c(-20,-15,-15,-20,-20),y=c(10,10,15,15,10)))
> pol=SpatialPolygons(list(Polygons(list(p), "ID")))
> suppressPackageStartupMessages(library(rgeos))
> stplot(sttdf[pol])
> names(sttdf[pol]@traj)
[1] "3"
> stplot(sttdf[1:2],col=1:2)
> stplot(sttdf[,t0])
> stplot(sttdf[,"2013"])
> stplot(sttdf[pol,"2013"])
> is.null(sttdf[pol,t0])
[1] TRUE
> 
> proc.time()
   user  system elapsed 
  0.919   0.051   0.961