33  numeric

ImportantDisclaimer

These packages (Note 1) are a one-person project undergoing rapid evolution. Backward compatibility (per Hadley Wickham) is provided as a courtesy rather than a guarantee.

Until further notice, these packages should

  • not be used as a basis for research grant applications,
  • not be cited as an actively maintained tool in a peer-reviewed manuscript,
  • not be used to support or fulfill requirements for pursuing an academic degree.

In addition, work primarily based on these packages (Note 1) should not be presented at academic conferences or similar scholarly venues.

Furthermore, a person’s ability to use these packages (Note 1) does not necessarily imply an understanding of their underlying mechanisms. Accordingly, demonstration of their use alone should not be considered sufficient evidence of expertise, nor should it be credited as a basis for academic promotion or advancement.

These statements do not apply to the contributors (Tip 1) to these packages (Note 1) with respect to their specific contributions.

These statements do not apply when the maintainer of these packages (Note 1), Tingting Zhan, is credited as the first author, the lead author, and/or the corresponding author in a peer-reviewed manuscript, or as the Principal Investigator or Co-Principal Investigator in a research grant application and/or a final research progress report.

These statements are advisory in nature and do not modify or restrict the rights granted under the GNU General Public License https://www.r-project.org/Licenses/.

The function numeric() creates a numeric scalar or vector, i.e., an R object of S3 class 'numeric'.

Note

The examples in Chapter 33 require

library(groupedHyperframe)

Package groupedHyperframe (v0.4.0, GPL-2) implements the following S3 methods to the class 'numeric' (Table 33.1),

Table 33.1: S3 methods groupedHyperframe::*.numeric (v0.4.0)
visible generic isS4
as.raster.numeric FALSE grDevices::as.raster FALSE
cumvtrapz.numeric FALSE groupedHyperframe::cumvtrapz FALSE
glyphJust.numeric FALSE grDevices::glyphJust FALSE
kerndens.numeric FALSE groupedHyperframe::kerndens FALSE
visualize_vtrapz.numeric FALSE groupedHyperframe::visualize_vtrapz FALSE

33.1 Kernel Density Estimates

The S3 generic function kerndens() extracts the $y element of a density object. Package groupedHyperframe (v0.4.0, GPL-2) implements the following S3 methods (Table 33.2),

Table 33.2: S3 methods of groupedHyperframe::kerndens (v0.4.0)
visible isS4
kerndens.numeric FALSE FALSE
kerndens.ppp FALSE FALSE

The S3 method kerndens.numeric() is simply a wrapper of stats::density.default()$y.

Listing 33.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 10.10).

Listing 33.1: Example: function kerndens.numeric()
datasets::faithful$eruptions |> 
  kerndens(bw = 'sj') |>
  identical(
    y = datasets::faithful$eruptions |> 
      density(bw = 'sj') |>
      getElement(name = 'y')
  ) |>
  stopifnot()

33.2 Cumulative Average Vertical Height of Trapzoidal Integration

The S3 method cumvtrapz.numeric() (Section 11.2, Table 11.1) has been explained in Section 11.2.

The S3 method visualize_vtrapz.numeric() (Section 11.3, Table 11.2) calculate the cumulative average vertical height of the trapezoidal integration (Section 11.2) under the numeric vectors \(x\) and \(y\) (Listing 11.8, Figure 11.1).