/usr/share/doc/r-cran-sp/tests/agg.Rout.save is in r-cran-sp 1:1.2-5-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 58 59 | R version 3.2.4 Revised (2016-03-16 r70336) -- "Very Secure Dishes"
Copyright (C) 2016 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.
> library(sp)
> g = SpatialGrid(GridTopology(c(5,5), c(10,10), c(3,3)))
> p = as(g, "SpatialPolygons")
> p$z = c(1,0,1,0,1,0,1,0,1)
> cc = coordinates(g)
> p$ag1 = aggregate(p, p, mean)[[1]]
> p$ag1a = aggregate(p, p, mean, minDimension = 0)[[1]]
> p$ag2 = aggregate(p, p, mean, minDimension = 1)[[1]]
> p$ag3 = aggregate(p, p, mean, minDimension = 2)[[1]]
> p$ag4 = aggregate(p, p, mean, areaWeighted=TRUE)[[1]]
Warning message:
In aggregate.Spatial(p, p, mean, areaWeighted = TRUE) :
argument FUN is ignored in area-weighted aggregation, see documentation
> pts = cbind(c(9,21,21,9,9),c(9,9,21,21,9))
> sq = SpatialPolygons(list(Polygons(list(Polygon(pts)), "ID")))
> rnd2 = function(x) round(x, 2)
> l = list(
+ list("sp.text", cc, rnd2(p$z), which = 1),
+ list("sp.text", cc, rnd2(p$ag1), which = 2),
+ list("sp.text", cc, rnd2(p$ag1a), which = 3),
+ list("sp.text", cc, rnd2(p$ag2), which = 4),
+ list("sp.text", cc, rnd2(p$ag3), which = 5),
+ list("sp.text", cc, rnd2(p$ag4), which = 6),
+ list(sq, col = 'green', which = 6, first = FALSE, lwd = 2)
+ )
> spplot(p, names.attr = c("source", "default aggregate", "minDimension=0",
+ "minDimension=1", "minDimension=2", "areaWeighted=TRUE"), layout = c(3,2),
+ as.table=TRUE, col.regions=bpy.colors(151)[50:151], cuts=100,
+ sp.layout = l, scales = list(draw = TRUE))
>
> rnd2(c(aggregate(p, sq, mean)[[1]],
+ aggregate(p, sq, mean, minDimension = 0)[[1]],
+ aggregate(p, sq, mean, minDimension = 1)[[1]],
+ aggregate(p, sq, mean, minDimension = 2)[[1]],
+ aggregate(p, sq, mean, areaWeighted=TRUE)[[1]]))
[1] 0.56 0.56 0.56 0.56 0.72
Warning message:
In aggregate.Spatial(p, sq, mean, areaWeighted = TRUE) :
argument FUN is ignored in area-weighted aggregation, see documentation
>
> proc.time()
user system elapsed
0.932 0.312 0.939
|