7  About

R terminology may differ from that commonly used in mathematics and statistics. For explanations and references to the terms and abbreviations used in this Quarto book, please refer to Chapter 35.

7.1 Environment

This Quarto book is created under R version 4.5.1 (2025-06-13) with the aid of packages knitr (Xie 2025, v1.50; 2015; 2014), quarto (Allaire and Dervieux 2024, v1.5.1 with Quarto v1.8.25) and rmarkdown (Allaire et al. 2025, v2.30; Xie, Allaire, and Grolemund 2018; Xie, Dervieux, and Riederer 2020). Documentation and check are supported by packages roxygen2 (Wickham, Danenberg, et al. 2025, v7.3.3) and devtools (Wickham, Hester, et al. 2025, v2.4.6).

An Integrated Development Environment (IDE), e.g., RStudio (Posit Team 2025) or Positron, is not required, but highly recommended.

7.2 Enhancement

7.2.1 groupedHyperframe (v0.3.0.20251020)

Package groupedHyperframe Enhances the spatstat.* family of packages (Baddeley, Rubak, and Turner 2015; Baddeley and Turner 2005).

Package groupedHyperframe Enhances package spatstat.explore (v3.5.3.3), with

Package groupedHyperframe Enhances package spatstat.geom (v3.6.0.3), with

  • new S3 class 'groupedHyperframe' (Chapter 2, Section 3.1, Chapter 16) that inherits from the class 'hyperframe'
  • additional S3 method dispatches to ppp.object (Chapter 23)
  • additional S3 method dispatches to the class 'tess' (Chapter 26)
  • additional S3 method dispatches to the class 'anylist' (Chapter 11)
  • additional S3 method dispatches to the class 'solist' (Chapter 25)
  • additional S3 method dispatches to the class 'ppplist' (Chapter 24)
  • additional S3 method dispatches to the class 'hyperframe' (Chapter 17)
  • new S3 class 'vectorlist' (Chapter 27) that inherits from the class 'anylist'
  • new S3 class 'fvlist' (Chapter 14) that inherits from the class 'anylist'

7.2.2 groupedHyperframe.random (v0.2.0)

Package groupedHyperframe.random Enhances the package spatstat.random (v3.4.2.3).

The authors sincerely thank Prof. Adrian Baddeley for recognizing their submitted suggestions and/or bug reports in

  • package spatstat.explore version 3.4-0.
  • package spatstat.geom version 3.3-5.

7.2.3 hyper.gam (v0.2.1)

Package hyper.gam Enhances the package mgcv (Wood 2017, v1.9.3), with

  • generalized additive models using a predictor of hypercolumn

7.3 Dependency

These packages all Imports packages

Some of these packages Imports or Suggests packages

7.3.1 groupedHyperframe (v0.3.0.20251020)

Package groupedHyperframe Imports packages

Package groupedHyperframe Suggests packages

7.3.2 groupedHyperframe.random (v0.2.0)

Package groupedHyperframe.random Depends on package

  • groupedHyperframe (v0.3.0.20251020)

Package groupedHyperframe.random Imports packages

  • MASS (Venables and Ripley 2002, v7.3.65), for function MASS::mvrnorm()
  • spatstat.geom (v3.6.0.3) and spatstat.random (v3.4.2.3), for operation and simulation of ppp.object and marks

7.3.3 hyper.gam (v0.2.1)

Package hyper.gam Depends package

  • groupedHyperframe (v0.3.0.20251020)

Package hyper.gam Imports packages

Package hyper.gam Suggests packages

7.3.4 maxEff (v0.2.1)

Package maxEff Depends package

  • groupedHyperframe (v0.3.0.20251020)

Package maxEff Imports packages

Package maxEff Suggests packages

7.3.5 Function Name Conflicts

A function name conflict exists between

when loading both packages

  • groupedHyperframe (v0.3.0.20251020), which Imports package spatstat.explore (v3.5.3.3)
  • hyper.gam (v0.2.1), which Imports package caret (v7.0.1) which Imports package pROC (v1.19.0.1)

This function name clash is potentially hazardous as the S3 classes, both named 'roc', created by functions spatstat.explore::roc() and pROC::roc() are totally different.

7.4 Development Version

The development version of these packages, which includes experimental and potentially unstable features, is released extremely frequently to Github. To reproduce all examples in this Quarto book, readers must also install the development versions of the spatstat.* family of packages.

Readers should repeat the calls to function pak::pak() (Csárdi and Hester 2025) until each call prints the message

ℹ No downloads are needed

Review: function pak::pak() (Csárdi and Hester 2025), install development versions
pak::pak('spatstat/spatstat', ask = FALSE)
pak::pak('spatstat/spatstat.data', ask = FALSE)
pak::pak('spatstat/spatstat.explore', ask = FALSE)
pak::pak('spatstat/spatstat.geom', ask = FALSE)
pak::pak('spatstat/spatstat.linnet', ask = FALSE)
pak::pak('spatstat/spatstat.model', ask = FALSE)
pak::pak('spatstat/spatstat.random', ask = FALSE)
pak::pak('spatstat/spatstat.sparse', ask = FALSE)
pak::pak('spatstat/spatstat.univar', ask = FALSE)
pak::pak('spatstat/spatstat.utils', ask = FALSE)

pak::pak('tingtingzhan/groupedHyperframe', ask = FALSE)
pak::pak('tingtingzhan/groupedHyperframe.random', ask = FALSE)
pak::pak('tingtingzhan/hyper.gam', ask = FALSE)
pak::pak('tingtingzhan/maxEff', ask = FALSE)

Alternatively, readers should repeat the calls to function remotes::install_github() (Csárdi et al. 2024) until each call prints the message,

Skipping install of '_PACKAGE_' from a github remote, the SHA1 (_0000000d_) has not changed since last install.

Review: function remotes::install_github() (Csárdi et al. 2024), install development versions
remotes::install_github('spatstat/spatstat', upgrade = 'always')
remotes::install_github('spatstat/spatstat.data', upgrade = 'always')
remotes::install_github('spatstat/spatstat.explore', upgrade = 'always')
remotes::install_github('spatstat/spatstat.geom', upgrade = 'always')
remotes::install_github('spatstat/spatstat.linnet', upgrade = 'always')
remotes::install_github('spatstat/spatstat.model', upgrade = 'always')
remotes::install_github('spatstat/spatstat.random', upgrade = 'always')
remotes::install_github('spatstat/spatstat.sparse', upgrade = 'always')
remotes::install_github('spatstat/spatstat.univar', upgrade = 'always')
remotes::install_github('spatstat/spatstat.utils', upgrade = 'always')

remotes::install_github('tingtingzhan/groupedHyperframe', upgrade = 'always')
remotes::install_github('tingtingzhan/groupedHyperframe.random', upgrade = 'always')
remotes::install_github('tingtingzhan/hyper.gam', upgrade = 'always')
remotes::install_github('tingtingzhan/maxEff', upgrade = 'always')

Table 7.1 tracks of the development versions of the spatstat.* family of packages on Github that are ahead of CRAN. It is refreshed daily.

Table: development version of spatstat.* family ahead of CRAN
spatstat = c(
  'spatstat', 'spatstat.data', 'spatstat.explore', 'spatstat.geom', 'spatstat.linnet', 
  'spatstat.model', 'spatstat.random', 'spatstat.sparse', 'spatstat.univar', 'spatstat.utils'
)
cran = available.packages(contriburl = 'https://cran.rstudio.com/src/contrib') |> 
  as.data.frame.matrix() |>
  subset.data.frame(subset = Package %in% spatstat, select = c('Package', 'Version'))
github = installed.packages() |>
  as.data.frame.matrix() |>
  subset.data.frame(subset = Package %in% spatstat, select = c('Package', 'Version'))
merge.data.frame(x = cran, y = github, by = 'Package', suffixes = c(' on CRAN', ' on Github')) |> 
  subset.data.frame(subset = `Version on CRAN` != `Version on Github`) |>
  within.data.frame(expr = {
    Package = Package |> sprintf(fmt = '**`%s`**')
  }) |>
  knitr::kable(
    row.names = FALSE,
    caption = Sys.Date() |> format() |> 
      sprintf(fmt = 'Development version of `spatstat.*` family ahead of CRAN, as of %s')
  )
Table 7.1: Development version of spatstat.* family ahead of CRAN, as of 2025-10-21
Package Version on CRAN Version on Github
spatstat.explore 3.5-3 3.5-3.003
spatstat.geom 3.6-0 3.6-0.003
spatstat.linnet 3.3-2 3.3-2.001
spatstat.model 3.4-2 3.4-2.001
spatstat.random 3.4-2 3.4-2.003
spatstat.univar 3.1-4 3.1-4.001

7.5 Use of Namespace

In this Quarto book, the authors make a deliberate effort to avoid using library(), in order to keep the user’s search path as clean as possible. Instead, the authors use explicitly namespaced function calls, e.g., pracma::trapz() rather than loading the package with library(pracma) and calling trapz(), so that users can always identify the package from which a function originates.

The authors invoke library() only where it is strictly required and cannot be circumvented.

library() on these packages

To indicate that this is a Quarto book of these packages.

library(survival) in Chapter 5

To put the un-exported S3 method dispatch survival:::as.data.frame.Surv() on the search path. This is necessary, so that the function spatstat.geom::hyperframe() could recognize a survival, i.e., time-to-event, Surv-column instead of treating it as a matrix-hypercolumn.

library(spatstat.geom) and library(spatstat.explore) in the Appendix

These are necessary, so that the function utils::methods() could recognize from which package the S3 method dispatches are defined.

The authors make a concerted effort, for the benefit of junior statisticians, to call S3 method dispatches

explicitly without namespace, if they are exported from package base, stats, utils, etc.

e.g., the authors use within.data.frame() instead of

  • within() or
  • base::within() or
  • base::within.data.frame()

Obviously, it is impractical to use `[.data.frame`(cars, 'speed') instead of cars[, 'speed'] or cars$speed in R code-chunks. Readers are expected to be reasonably comfortable with the use of the .Primitive S3 generic functions base::`$` and base::`[`. The authors do not explicitly mention the S3 method dispatch base::`[.data.frame`() unless required by the context.

by their generic functions without namespace, if they are un-exported from package base, stats, utils, etc.

e.g., the authors use head() instead of

  • utils::head() or
  • utils:::head.default()
explicitly with namespace, no matter they are exported or un-exported from contributed packages other than these packages

e.g., the authors use spatstat.geom::with.hyperframe() instead of

  • library(spatstat.geom); with.hyperframe(), or
  • library(spatstat.geom); with().

e.g., the authors use spatstat.geom::print.ppp() instead of

  • library(spatstat.geom); print.ppp(), or
  • library(spatstat.geom); print(), or
  • library(spatstat.geom); (.)

e.g., the authors use patchwork:::ggplot_add.ggplot().

Obviously, it is impractical to use spatstat.geom::`$.hyperframe`(flu, 'pattern') instead of flu$pattern in R code-chunks. Readers are expected to be reasonably comfortable with the use of the .Primitive S3 generic function base::`$`. The authors will explicitly mention the S3 method dispatch spatstat.geom::`$.hyperframe`() in surrounding text to emphasize its different behavior.

by their generic functions without namespace, if they are defined in these packages

e.g., the authors use library(groupedHyperframe) in Chapter 5 and the .Primitive S3 generic function base::log() in Section 23.3, instead of

  • library(groupedHyperframe); log.ppp() or
  • groupedHyperframe::log.ppp().

All S3 method dispatches defined in these packages are exported.

The authors make a deliberate effort to reference data sets using their full namespaces.

data from package datasets shipped with R version 4.5.1 (2025-06-13)

e.g., the authors use datasets::penguins instead of

  • penguins or
  • data('penguins', package = 'datasets')
data from contributed packages other than these packages

e.g., the authors use spatstat.data::ants instead of

  • library(spatstat.data); ants or
  • data('ants', package = 'spatstat.data'); ants
data from these packages

e.g., the authors use library(groupedHyperframe) and Ki67 in Chapter 5, instead of

  • groupedHyperframe::Ki67 or
  • data('Ki67', package = 'groupedHyperframe'); Ki67