library(groupedHyperframe)
11 anylist
The examples in Chapter 11 require that the
search
path contains the followingnamespace
s,
Function spatstat.geom::anylist()
creates a list
of objects of any type, i.e., an R object of S3
class 'anylist'
, which inherits
from the class 'listof'
defined in package stats
shipped with R version 4.5.1 (2025-06-13). In addition to the existing S3
method dispatches spatstat.geom::*.anylist
(v3.6.0.3, Listing 11.1) and spatstat.explore::*.anylist
(v3.5.3.3, Listing 11.2),
S3
method dispatches spatstat.geom::*.anylist
Code
suppressPackageStartupMessages(library(spatstat.geom))
methods(class = 'anylist', all.names = TRUE) |>
attr(which = 'info', exact = TRUE) |>
subset.data.frame(subset = from == 'spatstat.geom')
# visible from generic isS4
# [.anylist TRUE spatstat.geom [ FALSE
# [<-.anylist TRUE spatstat.geom [<- FALSE
# as.hyperframe.anylist TRUE spatstat.geom as.hyperframe FALSE
# plot.anylist TRUE spatstat.geom plot FALSE
# print.anylist TRUE spatstat.geom print FALSE
# summary.anylist TRUE spatstat.geom summary FALSE
S3
method dispatches spatstat.explore::*.anylist
Code
suppressPackageStartupMessages(library(spatstat.explore))
methods(class = 'anylist', all.names = TRUE) |>
attr(which = 'info', exact = TRUE) |>
subset.data.frame(subset = from == 'spatstat.explore')
# visible from generic isS4
# collapse.anylist TRUE spatstat.explore collapse FALSE
# pool.anylist TRUE spatstat.explore pool FALSE
Package groupedHyperframe
(v0.3.0.20251020) implements more S3
method dispatches to the class 'anylist'
(Listing 11.3, Table 11.1),
S3
method dispatches groupedHyperframe::*.anylist
Code
methods2kable(class = 'anylist', package = 'groupedHyperframe', all.names = TRUE)
S3
method dispatches groupedHyperframe::*.anylist
(v0.3.0.20251020)
visible | from | generic | isS4 | |
---|---|---|---|---|
kerndens.anylist |
TRUE | groupedHyperframe | groupedHyperframe::kerndens |
FALSE |
quantile.anylist |
TRUE | groupedHyperframe | stats::quantile |
FALSE |
11.1 Kernel Density Estimates of numeric
-vector
s
The S3
method dispatch kerndens.anylist()
finds the kernel density
s of each numeric
-vector
member of an anylist
.
Example: function kerndens.anylist()
::anylist(
spatstat.geomrnorm(1e2L),
rnorm(1e2L)
|>
) kerndens(n = 8L)
# [[1]]
# [1] 0.0001161367 0.0111770062 0.0738221691 0.2798497894 0.3092550415 0.2036384279 0.0430319969 0.0001607981
#
# [[2]]
# [1] 0.0001295201 0.0199265325 0.1009740112 0.2883741979 0.3739260486 0.1672157755 0.0317010996 0.0001506271
Exception: function kerndens.anylist()
, no numeric
-vector
member
::Kovesi$values |>
spatstat.datasapply(FUN = class) |>
unique.default()
# [1] "character"
::Kovesi$values |>
spatstat.datakerndens() |>
is.null()
# [1] TRUE
11.2 Quantile of numeric
-vector
s
The S3
method dispatch quantile.anylist()
finds the quantile
s of each numeric
-vector
member of an anylist
.
Example: function quantile.anylist()
::anylist(
spatstat.geomrnorm(1e2L),
rnorm(1e2L)
|>
) quantile()
# [[1]]
# 0% 25% 50% 75% 100%
# -2.3645586 -0.5335547 -0.1156894 0.4684773 1.8108271
#
# [[2]]
# 0% 25% 50% 75% 100%
# -2.37859630 -0.67601565 0.05162509 0.68971708 2.59814245
Exception: function quantile.anylist()
, no numeric
-vector
member
::Kovesi$values |>
spatstat.datasapply(FUN = class) |>
unique.default()
# [1] "character"
::Kovesi$values |>
spatstat.dataquantile() |>
is.null()
# [1] TRUE
11.3 Split
Section 11.3 is intended as an educational handbook for beginners to R version 4.5.1 (2025-06-13) and package
spatstat.geom
(v3.6.0.3). This section does not discuss the functionality of packagegroupedHyperframe
(v0.3.0.20251020).
The default
dispatch of the S3
generic function base::split()
splits an anylist
into a list
of anylist
. This feature is made possible by the magic of the S3
method dispatch spatstat.geom::`[.anylist`
.
Listing 11.4 splits a spatial-object list (solist
, Chapter 25) vesicles.extra
(Section 8.20) into a list
of solist
.
base::split.default()
on solist
= spatstat.data::vesicles.extra |>
v1 split.default(f = factor(c('a', 'a', 'b', 'b')))
= spatstat.data::vesicles.extra |>
v2 split(f = factor(c('a', 'a', 'b', 'b')))
stopifnot(identical(v1, v2))
Listing 11.5 splits a pixel-image-object list (imlist
, Chapter 20) gorillas.extra
(Section 8.12) into a list
of imlist
.
base::split.default()
on imlist
= spatstat.data::gorillas.extra |>
g1 split.default(f = factor(c('a', 'a', 'b', 'b', 'c', 'c', 'c')))
= spatstat.data::gorillas.extra |>
g2 split(f = factor(c('a', 'a', 'b', 'b', 'c', 'c', 'c')))
stopifnot(identical(g1, g2))
Listing 11.6 splits a point-pattern-object list (ppplist
, Chapter 24) waterstriders
(Section 8.21) into a list
of ppplist
.
base::split.default()
on ppplist
= spatstat.data::waterstriders |>
w1 split.default(f = factor(c('a', 'a', 'b')))
= spatstat.data::waterstriders |>
w2 split(f = factor(c('a', 'a', 'b')))
stopifnot(identical(w1, w2))