15  anylist

The function anylist() (v3.7.3, GPL (>= 2)) creates a list of objects of any type, i.e., an R object of S3 class 'anylist', which inherits from the classes 'listof' and 'list' (R version 4.5.3 (2026-03-11)). Listing 15.1 summarizes the S3 methods for the class 'anylist' in the spatstat.* family of packages,

Listing 15.1: S3 methods spatstat.*::*.anylist
Code
library(spatstat)
.S3methods(class = 'anylist', all.names = TRUE) |> 
  attr(which = 'info', exact = TRUE) |>
  subset.data.frame(subset = grepl(pattern = '^spatstat\\.', x = from))
#                       visible             from       generic  isS4
# [.anylist                TRUE    spatstat.geom             [ FALSE
# [<-.anylist              TRUE    spatstat.geom           [<- FALSE
# as.hyperframe.anylist    TRUE    spatstat.geom as.hyperframe FALSE
# collapse.anylist         TRUE spatstat.explore      collapse FALSE
# plot.anylist             TRUE    spatstat.geom          plot FALSE
# pool.anylist             TRUE spatstat.explore          pool FALSE
# print.anylist            TRUE    spatstat.geom         print FALSE
# summary.anylist          TRUE    spatstat.geom       summary FALSE

Package groupedHyperframe (v0.4.0, GPL-2) does not implement any S3 method to the class 'anylist'.

15.1 Split

Note

Section 15.1 is intended as an educational piece for beginners to R version 4.5.3 (2026-03-11) and package spatstat.geom (v3.7.3, GPL (>= 2)).

Section 15.1 does not discuss the feature of package groupedHyperframe (v0.4.0, GPL-2).

The default method of the S3 generic function split() splits an anylist into a list-of-anylist. This feature is made possible by the magic of the S3 method `[.anylist` (v3.7.3, GPL (>= 2)).

Listing 15.2 splits a spatial-object list (solist, Chapter 39) vesicles.extra (Section 10.25) into a list-of-solist.

Listing 15.2: Review: function split.default() on solist
spatstat.data::vesicles.extra |>
  split.default(f = factor(c('a', 'a', 'b', 'b'))) |> 
  lapply(FUN = class)
# $a
# [1] "solist"  "anylist" "listof"  "list"   
# 
# $b
# [1] "solist"  "anylist" "listof"  "list"

Listing 15.3 splits a pixel-image-object list (imlist, Chapter 29) gorillas.extra (Section 10.14) into a list-of-imlist.

Listing 15.3: Review: function split.default() on imlist
spatstat.data::gorillas.extra |>
  split.default(f = factor(c('a', 'a', 'b', 'b', 'c', 'c', 'c'))) |> 
  lapply(FUN = class)
# $a
# [1] "imlist"  "solist"  "anylist" "listof"  "list"   
# 
# $b
# [1] "imlist"  "solist"  "anylist" "listof"  "list"   
# 
# $c
# [1] "imlist"  "solist"  "anylist" "listof"  "list"

Listing 15.4 splits a point-pattern-object list (ppplist, Chapter 37) waterstriders (Section 10.26) into a list-of-ppplist.

Listing 15.4: Review: function split.default() on ppplist
spatstat.data::waterstriders |>
  split.default(f = factor(c('a', 'a', 'b'))) |> 
  lapply(FUN = class)
# $a
# [1] "ppplist" "solist"  "anylist" "listof"  "list"   
# 
# $b
# [1] "ppplist" "solist"  "anylist" "listof"  "list"