aggregate_fv {groupedHyperframe}R Documentation

Aggregate fv.objects by Cluster

Description

Aggregate information in fv.objects by sample clustering.

Usage

aggregate_fv(
  X,
  by = stop("must specify `by`"),
  f_aggr_ = pmean,
  mc.cores = switch(.Platform$OS.type, windows = 1L, detectCores()),
  ...
)

Arguments

X

a groupedHyperframe, containing one or more fv.object column(s)

by

one-sided formula, sample clustering. Use only one-level hierarchy (e.g., ~patient or ~image). Do not use multi-level hierarchy (e.g., ~patient/image)

f_aggr_

see function aggregate_by_()

mc.cores

integer scalar, see function mclapply. Default is 1L on Windows, or detectCores on Mac. CRAN requires mc.cores <= 2L in examples.

...

additional parameters, currently not in use

Value

Function aggregate_fv() returns a data.frame, with aggregated information stored in matrix-columns.

Note that hyperframe does not support matrix-column (for good reasons!). Therefore, function aggregate_fv() must return a data.frame, instead of a hyperframe.

Examples

library(spatstat.data)
library(spatstat.geom)
flu$pattern[] = flu$pattern |> 
 lapply(FUN = `mark_name<-`, value = 'stain') # read ?flu carefully
r = seq.int(from = 0, to = 100, by = 5)
flu |>
 subset(stain == 'M2-M1') |>
 Gcross_(i = 'M1', j = 'M2', r = r, correction = 'best', mc.cores = 1L) |>
 as.groupedHyperframe(group = ~ virustype/frameid) |>
 aggregate_fv(by = ~ virustype, mc.cores = 1L)

[Package groupedHyperframe version 0.2.1 Index]