library(groupedHyperframe)32 numeric
Function base::numeric() creates a numeric scalar or vector, i.e., an R object of S3 class 'numeric'.
The examples in Chapter 32 require
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" "splines"
# [64] "stats" "survival" "systemfonts" "tensor" "textshaping" "tibble" "tidyselect" "tools" "utils"
# [73] "vctrs" "viridisLite" "xfun" "yaml"Package groupedHyperframe (v0.3.4) implements the following S3 methods to the class 'numeric' (Table 32.1),
S3 methods groupedHyperframe::*.numeric (v0.3.4)
| visible | generic | isS4 | |
|---|---|---|---|
cumvtrapz.numeric |
TRUE | groupedHyperframe::cumvtrapz |
FALSE |
kerndens.numeric |
TRUE | groupedHyperframe::kerndens |
FALSE |
visualize_vtrapz.numeric |
TRUE | groupedHyperframe::visualize_vtrapz |
FALSE |
32.1 Kernel Density Estimates
The S3 generic function kerndens() extracts the $y element of a density object. Package groupedHyperframe (v0.3.4) implements the following S3 methods (Table 32.2),
S3 methods of groupedHyperframe::kerndens (v0.3.4)
| visible | isS4 | |
|---|---|---|
kerndens.anylist |
TRUE | FALSE |
kerndens.hyperframe |
TRUE | FALSE |
kerndens.numeric |
TRUE | FALSE |
kerndens.ppp |
TRUE | FALSE |
kerndens.ppplist |
TRUE | FALSE |
The S3 method kerndens.numeric() is simply a wrapper of stats::density.default()$y.
Listing 32.1 finds the kernel density estimates of the eruption time in minutes of the Old Faithful geyser in Yellowstone National Park, Wyoming, USA, in the data frame faithful (Section 9.10).
kerndens.numeric()
datasets::faithful$eruptions |>
kerndens(bw = 'sj') |>
identical(
y = datasets::faithful$eruptions |>
density(bw = 'sj') |>
getElement(name = 'y')
) |>
stopifnot()32.2 Cumulative Average Vertical Height of Trapzoidal Integration
The S3 method cumvtrapz.numeric() (Section 10.2, Table 10.1) has been explained in Section 10.2.
The S3 method visualize_vtrapz.numeric() (Section 10.3, Table 10.2) calculate the cumulative average vertical height of the trapezoidal integration (Section 10.2) under the numeric vectors \(x\) and \(y\) (Listing 10.8, Figure 10.1).