18  data.frame

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 data.frame() creates a data frame, i.e., an R object of S3 class 'data.frame'. Note 18.1 summarizes the S3 methods for the class 'data.frame' in the spatstat.* family of packages,

S3 methods *.data.frame
visible from generic isS4
as.fv.data.frame TRUE spatstat.explore spatstat.explore::as.fv FALSE
as.hyperframe.data.frame TRUE spatstat.geom spatstat.geom::as.hyperframe FALSE
as.im.data.frame TRUE spatstat.geom spatstat.geom::as.im FALSE
as.owin.data.frame TRUE spatstat.geom spatstat.geom::as.owin FALSE
as.ppp.data.frame TRUE spatstat.geom spatstat.geom::as.ppp FALSE
as.psp.data.frame TRUE spatstat.geom spatstat.geom::as.psp FALSE
multiplicity.data.frame TRUE spatstat.geom spatstat.geom::multiplicity FALSE
uniquemap.data.frame TRUE spatstat.univar spatstat.univar::uniquemap FALSE
TipExamples in Chapter 18 Require
library(groupedHyperframe)

18.1 Aggregate to (Grouped) Hyper Data Frame

The S3 generic function aggregate2hyper() aggregates an R object into a (grouped) hyper data frame. Package groupedHyperframe (v0.4.0, GPL-2) implements the following S3 methods (Table 18.1),

Table 18.1: S3 methods of groupedHyperframe::aggregate2hyper (v0.4.0)
visible isS4
aggregate2hyper.data.frame FALSE FALSE
aggregate2hyper.groupedData FALSE FALSE

The S3 method aggregate2hyper.data.frame() aggregates a data frame with substantial amount of duplicated information into a (grouped) hyper data frame.

In Chapter 2, Listing 2.1, Listing 2.2,

  1. inspects the input data frame lung0 (Listing 2.1) by the user-specified (nested) grouping structure, e.g., image_id nested in patient_id;
  2. identifies the input data frame column(s) with non-identical elements within the lowest group, e.g., the numeric column lung0$hladr and the factor column lung0$phenotype;
  3. converts these column(s) into the hypercolumn(s) of the output grouped hyper data frame (Listing 2.2), e.g., the numeric-hypercolumn lung_g$hladr and the factor-hypercolumn lung_g$phenotype. Each row of the output grouped hyper data frame (Listing 2.2) represents the lowest group of the nested grouping structure.