19  function

Function `function` creates an R function, i.e., an R object of S3 class 'function'. Listing 19.1 summarizes the S3 methods for the class 'function' in the spatstat.* family of packages,

Listing 19.1: S3 methods spatstat.*explore*::*.function
Code
suppressPackageStartupMessages(library(spatstat))
.S3methods(class = 'function', all.names = TRUE) |> 
  attr(which = 'info', exact = TRUE) |>
  subset.data.frame(subset = grepl(pattern = '^spatstat\\.', x = from))
#                       visible             from      generic  isS4
# as.im.function           TRUE    spatstat.geom        as.im FALSE
# as.linim.function        TRUE  spatstat.linnet     as.linim FALSE
# clusterfield.function    TRUE  spatstat.random clusterfield FALSE
# roc.function             TRUE spatstat.explore          roc FALSE

The examples in Chapter 19 require

library(groupedHyperframe)
search path & loadedNamespaces on author’s computer
search()
#  [1] ".GlobalEnv"                "package:groupedHyperframe" "package:stats"             "package:graphics"          "package:grDevices"         "package:utils"             "package:datasets"         
#  [8] "package:methods"           "Autoloads"                 "package:base"
loadedNamespaces() |> sort.int()
#  [1] "abind"             "base"              "cli"               "cluster"           "codetools"         "compiler"          "datasets"          "deldir"            "digest"           
# [10] "doParallel"        "dplyr"             "evaluate"          "farver"            "fastmap"           "fastmatrix"        "foreach"           "generics"          "geomtextpath"     
# [19] "GET"               "ggplot2"           "glue"              "goftest"           "graphics"          "grDevices"         "grid"              "gridExtra"         "groupedHyperframe"
# [28] "gtable"            "htmltools"         "htmlwidgets"       "iterators"         "jsonlite"          "knitr"             "lattice"           "lifecycle"         "magrittr"         
# [37] "Matrix"            "matrixStats"       "methods"           "nlme"              "otel"              "parallel"          "patchwork"         "pillar"            "pkgconfig"        
# [46] "polyclip"          "pracma"            "R6"                "RColorBrewer"      "rlang"             "rmarkdown"         "rstudioapi"        "S7"                "scales"           
# [55] "SpatialPack"       "spatstat.data"     "spatstat.explore"  "spatstat.geom"     "spatstat.random"   "spatstat.sparse"   "spatstat.univar"   "spatstat.utils"    "stats"            
# [64] "systemfonts"       "tensor"            "textshaping"       "tibble"            "tidyselect"        "tools"             "utils"             "vctrs"             "viridisLite"      
# [73] "xfun"              "yaml"

Table 19.1 summarizes the S3 methods for the class 'function' in package groupedHyperframe (v0.3.2.20251225),

Table 19.1: S3 methods groupedHyperframe::*.function (v0.3.2.20251225)
visible from generic isS4
visualize_vtrapz.function TRUE groupedHyperframe groupedHyperframe::visualize_vtrapz FALSE

19.1 Cumulative Average Vertical Height of Trapzoidal Integration

The S3 method visualize_vtrapz.function() (Section 11.2, Table 11.2)

  1. checks, in the enclosing environment of the input function \(f(x)\), for
  2. creates an \(x\)-grid using the numeric vector x (or z$x) and the number of equally spaced points with a default value of n=513L;
  3. connects the \((x, f(x))\) dots at the \(x\)-grid;
  4. scatter-plots the x (or z$x) and y (or z$y) dots.